42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace WZ
|
|
{
|
|
public class EditorFileUtils
|
|
{
|
|
public static List<string> GetAllFileWhereSuffix(string projectPath, string suffix)
|
|
{
|
|
return ListFiles(projectPath).Where(file => file.EndsWith(suffix)).ToList();
|
|
}
|
|
|
|
|
|
public static List<string> ListFiles(string path, List<string> fileList = null)
|
|
{
|
|
fileList ??= new List<string>();
|
|
|
|
try
|
|
{
|
|
// 获取当前目录下所有文件
|
|
var files = Directory.GetFiles(path);
|
|
fileList.AddRange(files);
|
|
|
|
// 递归获取子文件夹中的所有文件
|
|
var subdirectories = Directory.GetDirectories(path);
|
|
foreach (var subdirectory in subdirectories)
|
|
{
|
|
ListFiles(subdirectory, fileList);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LoggerUtils.Error("An error occurred: " + e.Message);
|
|
}
|
|
|
|
return fileList;
|
|
}
|
|
}
|
|
} |