How to check if any .txt
file exists in a folder?
If the folder still have .txt
file output a error messagebox.
Thx all! Actually i want to make a function can check any .txt file exists in a folder. If yes write a error message to eventLog. Final My code:
System.Diagnostics.EventLog appLog = new System.Diagnostics.EventLog();
DirectoryInfo di = new DirectoryInfo(@"c:/Users/Public/Definitions");
FileInfo[] TXTFiles = di.GetFiles("*.txt");
foreach (var fi in TXTFiles)
{
if (fi.Exists)
{
appLog.Source = "Definitions Folder still have text files";
appLog.WriteEntry("Still have txt files.");
}
}