解决方法
您可以在文件阵列上使用
OrderBy.
DirectoryInfo dir = new DirectoryInfo(@"C:\yourfolder"); FileInfo[] files = dir.GetFiles(); //User Enumerable.OrderBy to sort the files array and get a new array of sorted files FileInfo[] sortedFiles = files.OrderBy(r => r.Name).ToArray();
FileInfo[] sortedFiles = files .OrderBy(r => int.Parse(Path.GetFileNameWithoutExtension(r.Name))) .ToArray();