public class DirectoryAllFiles
{
static List<FileInfomation> FileList = new List<FileInfomation>();
public static List<FileInfomation> GetAllFiles(DirectoryInfo dir)
{
FileInfo[] allFile = dir.GetFiles();
foreach (FileInfo fi in allFile)
{
FileList.Add(new FileInfomation {
FileName = fi.Name, FilePath = fi.FullName });
}
DirectoryInfo[] allDir = dir.GetDirectories();
foreach (DirectoryInfo d in allDir)
{
GetAllFiles(d);
}
return FileList;
}
static List<string> FileFolderList = new List<string>();
static List<string> desFileFolderList = new List<string>();
static string Editor = "\\" + "Editor";
static string Editors = "\\" + "Editor" + "\\";
static string Resources = "\\" + "Resources";
static string Resourcess = "\\" + "Resources" + "\\";
static string Scripts = "\\" + "Scripts";
static string Scriptss = "\\" + "Scripts" + "\\";
static string Prefab = "\\" + "Prefab";
static string Scenes = "\\" + "Scenes";
static string StreamingAssets = "\\" + "StreamingAssets";
static string Shader = "\\" + "Shader";
public static void FileReName(DirectoryInfo dir)
{
string addContent = "August16";
DirectoryInfo[] allDir = dir.GetDirectories();
foreach (DirectoryInfo d in allDir)
{
if (isSaveNext(d.FullName))
{
FileFolderList.Add(d.FullName);
string temp = d.FullName + addContent;
desFileFolderList.Add(temp);
Debug.Log("文件夹:" + d.FullName);
}
FileReName(d);
}
for(int i=0;i<FileFolderList.Count;i++)
{
int index = FileFolderList.Count-1-i;
Directory.Move(FileFolderList[index], desFileFolderList[index]);
}
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
private static bool isSaveNext(string filename)
{
if(filename.Contains(Editor))
{
if(filename.Contains(Editors))
{
return true;
}
return false;
}
if(filename.Contains(Resources))
{
if(filename.Contains(Resourcess))
{
return true;
}
return false;
}
if(filename.Contains(Scripts))
{
if(filename.Contains(Scriptss))
{
return true;
}
return false;
}
if (filename.Contains(Prefab))
return false;
if (filename.Contains(Scenes))
return false;
if (filename.Contains(StreamingAssets))
return false;
return true;
}
C#更改文件夹拓展 Unity
猜你喜欢
转载自blog.csdn.net/charlsdm/article/details/126371297
今日推荐
周排行