Charles Sugden
asked on
Use .NET to delete tilde files
One of our production jobs gets a lot of tilde files (~*.doc) in its processing directory.
I'd like to remove them when this job starts up with a command like
file.delete("~*.doc")
but .net complains with an error
"Illegal characters in path."
How can I remove these files?
I'd like to remove them when this job starts up with a command like
file.delete("~*.doc")
but .net complains with an error
"Illegal characters in path."
How can I remove these files?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
public void deleteBogusFiles(string targetDir)
{
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(ta
foreach (System.IO.FileInfo fi in di.GetFiles())
{
string fn = fi.Name.ToString;
if (fn.StartsWith('~'))
{
System.IO.File.Delete(fn);
}
}
}