Here is the sample code for you. Steps will be read filespaths then getonly filenames from filepaths. Then add them in the list. Orderby list by filename. Then read actual files with already order filepath. Hope this is clear. Let me know if you have any questions.
//string[] filePaths = Directory.GetFiles("Directory Path");
string[] filePaths = new string[] { "a_001_200_x.txt", "ab_001_100_x.txt" };
List<FileInput> fileInput = new List<FileInput>();
foreach (string path in filePaths)
{
fileInput.Add(new FileInput
{
//here you can do Path.GetFileName(path).Substring(path.Length - 13, 13)
FileName = path.Substring(path.Length - 13, 13),
FilePath = path,
});
}
fileInput = fileInput.OrderBy(x => x.FileName).ToList();
foreach(var f in fileInput){
//Read your file here from the disk with sorted order.
}
public class FileInput
{
public string FileName { get; set; }
public string FilePath { get; set; }
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…