init: 导入项目到 meswork Gitea
This commit is contained in:
103
DataMirrorTools_Simulator/ModelBasic/Base/CopyFilesHandler.cs
Normal file
103
DataMirrorTools_Simulator/ModelBasic/Base/CopyFilesHandler.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
namespace CopyFiles
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CopyFilesHandler
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="strSouPath"></param>
|
||||
/// <param name="strDesPath"></param>
|
||||
public void CopyFiles(string strSouPath, string strDesPath)
|
||||
{
|
||||
Directory.CreateDirectory(strDesPath);
|
||||
|
||||
if (!Directory.Exists(strSouPath)) return;
|
||||
|
||||
string[] directories = Directory.GetDirectories(strSouPath);
|
||||
|
||||
if (directories.Length > 0)
|
||||
{
|
||||
foreach (string d in directories)
|
||||
{
|
||||
CopyFiles(d, strDesPath + d.Substring(d.LastIndexOf("\\")));
|
||||
}
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(strSouPath);
|
||||
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (string s in files)
|
||||
{
|
||||
string targetPath = strDesPath + s.Substring(s.LastIndexOf("\\"));
|
||||
|
||||
if (File.Exists(targetPath))
|
||||
{
|
||||
File.Delete(targetPath);
|
||||
}
|
||||
File.Copy(s, targetPath);
|
||||
currCount++;
|
||||
Console.WriteLine("" + currCount.ToString() + " / " + maxCount + " -> " + targetPath);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int currCount = 0;
|
||||
|
||||
int maxCount = 0;
|
||||
|
||||
List<String> fileNameLiat = new List<String>();
|
||||
|
||||
|
||||
public void GetFileCount(string strSouPath)
|
||||
{
|
||||
if (!Directory.Exists(strSouPath)) return ;
|
||||
|
||||
string[] directories = Directory.GetDirectories(strSouPath);
|
||||
|
||||
if (directories.Length > 0)
|
||||
{
|
||||
foreach (string d in directories)
|
||||
{
|
||||
GetFileCount(d);
|
||||
}
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(strSouPath);
|
||||
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (string s in files)
|
||||
{
|
||||
fileNameLiat.Add(s);
|
||||
}
|
||||
}
|
||||
maxCount = fileNameLiat.Count();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user