Sometime scenario arises where we need to delete a file using C#.
But sometime an error is thrown like "File is already in use. Not able to delete"
Here is the solution to delete that file
if(File.Exists(FullFileName))
{
GC.Collect();
GC.WaitForPendingFinalizers();
FileInfo f = new FileInfo(FullFileName);
f.Delete();
}
But sometime an error is thrown like "File is already in use. Not able to delete"
Here is the solution to delete that file
if(File.Exists(FullFileName))
{
GC.Collect();
GC.WaitForPendingFinalizers();
FileInfo f = new FileInfo(FullFileName);
f.Delete();
}