// (1) create test file and delete it again
File.Create(Path.Combine(folder, "testfile.empty"));
File.Delete(Path.Combine(folder, "testfile.empty"));
The last line throws an exception:
The process cannot access the file
‘\\MYPC\C$_AS\RSC\testfile.empty’
because it is being used by another
process.
Why is that?
File.Createhands you back a stream, that you haven’t closed.should work; or easier:
or even just: