|
-
March 27th, 2005, 03:53 AM
#1
Wite and Read to same file ERROR ?
I'm using StreamWriter to write to file and at the same time I'm using the StreamReader to read from the same file.
Doing that cause an exception when I'm trying to create the StreamReader when the file is already opened fro writing by the StreamWriter.
How can I write and read at the same time to the same file?
Thanks
Sahron
-
March 27th, 2005, 07:58 AM
#2
Re: Wite and Read to same file ERROR ?
You can use FileStream and FileAccess.ReadWrite access rights.
Something like:
Code:
FileStream s = new FileStream(name, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
Can read more in MSDN.
-
March 29th, 2005, 06:33 AM
#3
Re: Wite and Read to same file ERROR ?
Thanks,
I changed my code as you sugested and it works OK.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|