I wanted to know if it is possible to get all the names of text files in a certain folder.
For example, I have a folder with the name Maps, and I would like to get the names of all the text files in that folder and add it to a list of strings.
Is it possible, and if so, how I can achieve this?
DirectoryInfo d = new DirectoryInfo(@"D:\Test");//Assuming Test is your Folder
FileInfo[] Files = d.GetFiles("*.txt"); //Getting Text files
string str = "";
foreach(FileInfo file in Files )
{
str = str + ", " + file.Name;
}
Hope this will help...