I am creating the image of the PowerPoint file programmatically. And after saving the Images to the local drive I am getting the files using DirectoryInfo.GetFiles()
.
I am saving the image files with the sequence numbers.
My Files:
My issue is when I get the files, are not in the sequence I need them in.
The files sequence which I am getting in the FileInfo[]
is :
Can any one help me to solve this issue?
The function doesn't make any guarantees about order but you can achieve the desired result with a simple LINQ query;
FileInfo[] sortedFiles = DirectoryInfo.GetFiles().OrderByDescending(x => x.Name).ToArray();
Try this
foreach (FileInfo fi in directory.GetFiles().OrderBy(fi=>fi.FileName))
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With