how can I delete all files of a specific pattern except the present file that is using? I have tried like:
string temp_file_format = "ScriptLog_" + DateTime.Now.ToString("dd_MM_yyyy_HH") + "*";
System.IO.DirectoryInfo dir = new DirectoryInfo(path);
System.IO.FileInfo[] files = dir.GetFiles(temp_file_format);
foreach (FileInfo file in files)
{
file.Delete();
}
Suppose If I have 3 files with time stamp of 12:08, 12:09 and 12:12 and my application curently uses 12:15 log file, then it should delete the above 3 logs. Now what it does is that, it deletes the presently using file also..
any help would be really appreciated..