P
Phil396
I keep getting the error message
The process cannot access the file "---"
because it is being used by another process.
Here is the code where it crashes
string[] thefiles = Directory.GetFiles
(m_WorkingDir, "*.DEL");
foreach (string file in thefiles)
{
WriteLogEntry("Deleting : " + (new FileInfo
(file)).FullName);
try { File.Delete(file); }
catch { WriteLogEntry("** Delete failed."); }
}
}
}
I tried running this code in a console app
and it worked fine but in my program it crashes
any ideas of what is causing the problem
I found this code in a string helper class
FileStream myFile = File.Create(fileName);
and thought the File.Create might be causing the
problem but I changed the line to
FileStream myFile = new FileStream(fileName,
FileMode.Create);
However I also tested the code in a console app
and everything worked fine.
Any ideas what might be causing the problem.
The process cannot access the file "---"
because it is being used by another process.
Here is the code where it crashes
string[] thefiles = Directory.GetFiles
(m_WorkingDir, "*.DEL");
foreach (string file in thefiles)
{
WriteLogEntry("Deleting : " + (new FileInfo
(file)).FullName);
try { File.Delete(file); }
catch { WriteLogEntry("** Delete failed."); }
}
}
}
I tried running this code in a console app
and it worked fine but in my program it crashes
any ideas of what is causing the problem
I found this code in a string helper class
FileStream myFile = File.Create(fileName);
and thought the File.Create might be causing the
problem but I changed the line to
FileStream myFile = new FileStream(fileName,
FileMode.Create);
However I also tested the code in a console app
and everything worked fine.
Any ideas what might be causing the problem.