C# The process cannot access the file because it is being used by another process

Cannot delete file its being used by another process

delete file error the process cannot access the file because it is being used by another process.

the process cannot access the file because it is being used c#.

Solution

Type following code before your code

GC.Collect();
GC.WaitForPendingFinalizers();

 

About the Author

avatar