Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
StreamWriter Error
Message
From
10/02/2010 14:40:54
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01448574
Message ID:
01448629
Views:
20
>>>I am using a StreamReader to read through a file. When I find the phrase I'm looking for, I then replace it with some other text. It is all appended to a string. I then close the StreamReader, and attempt to replace the file's contents with the new stirng using a streamwriter.
>>>
>>>When I do
>>>
>>>
>>>.
>>>.
>>>.
>>>
>>>rdr.Close();
>>>
>>>StreamWriter wr = new StreamWriter(FileName);
>>>wr.Write(NewText);
>>>wr.Close();
>>>
>>>
>>>It errors on the StreamWriter saying the file is in use. You can see the Reader is closed.
>>
>>I think you must have the file open elsewhere.
>>
>>I do not have any problem
>>
>>ps: Why not use 'using' ?
>
>'Using' might be safer but providing Close() is called then it calls Dispose() so no difference from a practical POV?


I know, I know
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform