I need to get the first file name from a folder. How can I get this in C#?
The code below returns all the file names:
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 need the first file name.