I have some files in my directory.
09001-1.pdf, 09001-2.pdf, 09001-3.pdf, 09001-4.pdf, 09001-5.pdf, 09001-6.pdf, 09001-7.pdf, 09001-8.pdf, 09001-9.pdf, 09001-10.pdf, 09001-11.pdf, 09001-12.pdf, 09001-13.pdf in the same order.
When i wrote code for retrieving files from directory, I got output like this
09001-1.pdf, 09001-10.pdf, 09001-11.pdf, 09001-12.pdf, 09001-13.pdf, 09001-2.pdf, 09001-3.pdf, 09001-4.pdf, 09001-5.pdf, 09001-6.pdf, 09001-7.pdf, 09001-8.pdf, 09001-9.pdf
why is this and how can i get output in the same format as i have files in my directory? Please tell me.
Loading
Roei BarPosted Sep 10, 2009, 1:18 AM
DirectoryInfo info = new DirectoryInfo();
FileInfo[] files = info.GetFiles();
foreach (FileInfo _file in files)
{
Console.WriteLine(_file.Name);
}
Master BillaPosted Sep 10, 2009, 1:15 AM
When you are retrieve the file from the directory it sort like char base, so see your sequence came like on that way.
try this way
DirectoryInfo info = new DirectoryInfo();
FileInfo[] files = info.GetFiles();
May be help
thank you