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 -

python - Error: Unresolved reference 'selenium' What is the reason? -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -