I'm working with files on C#, my cose is supposed to delete some lines from a file as mentioned here:
 var tmpFile = Path.GetTempFileName(); 
 var LinesToKeep = File.ReadLines(path).Where(l => l.StartsWith("removeme")==false);            
 File.WriteAllLines(tmpFile, LinesToKeep);
 File.Delete(path);
 File.Move(tmpFile,path);
but I'm getting an exception: IOException was unhandled when running my code saying:
The process can not access the file because it is being used by another process
in the instruction: File.Delete(path);
How can check which process is using file, or there is another reason for my problem?
 
    