c# - IOException was unhandled -


this question has answer here:

i'm working files on c#, cose supposed delete lines file 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 exception: ioexception unhandled when running code saying:

the process can not access file because being used process

in instruction: file.delete(path); how can check process using file, or there reason problem?

use fileshare enumeration instruct os allow other processes (or other parts of own process) access same file concurrently.

using (var stream = file.open(path, filemode.open, fileaccess.write, fileshare.read)) { } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -