c# - Streamwriter crashes when writing to existing file -


here code have writes couple of files:

streamwriter writer = new streamwriter(@"c:\totalstock\data\points\" + stockname.toupper() + ".txt");  for(int = 0; < lines; i++) {    writer.writeline(linedata[i]);    postgui.send((object state) =>     {        progressbar2.performstep();     }, null); }  writer.close(); 

when delete text files , run code there no issue, when close application , run once more program gives me following error. causes error , can stop it?

error:

an unhandled exception of type 'system.io.ioexception' occurred in mscorlib.dll

additional information: process cannot access file 'c:\totalstock\data\points\ibm.txt' because being used process

as marc_s pointed out, error occurs because file trying edit opened application. if don't have file opened in other editor/viewer, problem may program itself.

if several instances of same code run concurrently , require access same file, in multithread environement.

does component in application read text file while trying write file?
application hang, , second instance requires same file?
run same tests each time?


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -