How to take first file name from a folder in C#
- by riad
Hi all,
I need to get the first file name from a folder .How i do it in C#?
My below code return all the file names.pls guide:
DirectoryInfo di = new DirectoryInfo(imgfolderPath);
foreach (FileInfo fi in di.GetFiles())
{
if (fi.Name != "." && fi.Name != ".." && fi.Name != "Thumbs.db")
{
string fileName = fi.Name;
string fullFileName = fileName.Substring(0, fileName.Length - 4);
MessageBox.Show(fullFileName);
}
}
I just need the first file name.pls guide
thanks
Riad