init: 导入项目到 meswork Gitea
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
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 ModelBasic
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CopyFilesHandler
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="strSouPath"></param>
|
||||
/// <param name="strDesPath"></param>
|
||||
public static 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static List<String> fileNameLiat = new List<String>();
|
||||
|
||||
|
||||
public static int GetFileCount(string strSouPath)
|
||||
{
|
||||
|
||||
if (!Directory.Exists(strSouPath)) return 0;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
return fileNameLiat.Count();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user