asp.net - IOException: The process cannot access the file 'filename' because it is being used by another process -


i have code in asp.net project:

protected void btnsave_click(object sender, eventargs e)     {         try         {             using (streamwriter sw = file.createtext(server.mappath(@"~/aboutus.txt")))             {                 sw.write(freetextbox1.text);                 sw.close();                 sw.dispose();                 lblerror.text = "تغییرات با موفقیت ذخیره شد.";                 lblerror.cssclass = "success";             }         }         catch (exception ex)         {             lblerror.text = "خطایی روی داده است!" + "\n" + ex.tostring();             lblerror.cssclass = "error";          }                 {             lblerror.visible = true;         }      } 

sometimes (not always) when hit btnsave following error occurred:

ioexception: process cannot access file 'filename' because being used process

why?

you run application after see windows task manager-->processes, notepad.exe running right click click end process . .


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -