|
|
@@ -267,6 +267,48 @@ public class FileHelper
|
|
|
return paths.ToArray();
|
|
|
}
|
|
|
|
|
|
+ public static string[] GetAllFileNmae_Only(string path, string include, bool isfullName = false, bool isGetSubPath = true, string perName = "")
|
|
|
+ {
|
|
|
+ List<string> paths = new List<string>();
|
|
|
+ string pername = string.IsNullOrEmpty(perName) ? "" : $"{perName}/";
|
|
|
+
|
|
|
+ if (Directory.Exists(path))
|
|
|
+ {
|
|
|
+ DirectoryInfo dir = new DirectoryInfo(path);
|
|
|
+ FileInfo[] fileInfos = dir.GetFiles();
|
|
|
+
|
|
|
+ foreach (var item in fileInfos)
|
|
|
+ {
|
|
|
+ if (include != null && !item.Name.EndsWith(include)) continue;
|
|
|
+
|
|
|
+ if (!isfullName)
|
|
|
+ {
|
|
|
+ paths.Add(pername + item.Name);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ paths.Add(item.FullName);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DirectoryInfo[] directoryInfos = dir.GetDirectories();
|
|
|
+ if (isGetSubPath)
|
|
|
+ {
|
|
|
+ if (directoryInfos != null && directoryInfos.Length > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in directoryInfos)
|
|
|
+ {
|
|
|
+ string[] names = GetAllFileNmae_Only(item.FullName, include, isfullName, isGetSubPath, pername + item.Name);
|
|
|
+ if (names != null && names.Length > 0)
|
|
|
+ {
|
|
|
+ paths.AddRange(names);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return paths.ToArray();
|
|
|
+ }
|
|
|
|
|
|
public static void CopyDir(string dir, string outDir, string exclude)
|
|
|
{
|
|
|
@@ -285,7 +327,23 @@ public class FileHelper
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ public static void CopyDir_Only(string dir, string outDir, string include)
|
|
|
+ {
|
|
|
+ string[] files1 = GetAllFileNmae_Only(dir, include);
|
|
|
+ if (dir.LastIndexOf('/') != dir.Length - 1)
|
|
|
+ {
|
|
|
+ dir += "/";
|
|
|
+ }
|
|
|
|
|
|
+ foreach (var item in files1)
|
|
|
+ {
|
|
|
+ Debug.Log("===============File : " + item);
|
|
|
+ byte[] fdatas = File.ReadAllBytes(dir + item);
|
|
|
+
|
|
|
+ WirteToFile($"{outDir}/{item}", fdatas);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
public static string GetSubPath(string path, string mainPath, bool isRemoveName = true)
|
|
|
{
|
|
|
|