Hi,

I have noticed that File.ReadAllText prevents other processes from writing
to the file while reading. It seems like the FileShare enum is set to Read
rather than ReadWrite. This is a bug in my opinion.

/m

Re: File.ReadAllText prevent write access for other processes by Vadym

Vadym
Wed Oct 10 05:23:37 PDT 2007

Hello, Marthin!

I do not think that its a bug. When you're reading from file you do not want
anybody to mess something in it, right?
That is if I'm reading _whole_ file I have to be shure that nothing will
change in it.

However, there may be scenarios when simultaneous read and write to the file
are permitted. When you have such scenario you'll have to use FileStream.
--
With best regards, Vadym Stetsiak.
Blog: http://vadmyst.blogspot.com

You wrote on Wed, 10 Oct 2007 04:44:01 -0700:

MF> Hi,

MF> I have noticed that File.ReadAllText prevents other processes from
MF> writing to the file while reading. It seems like the FileShare enum
MF> is set to Read rather than ReadWrite. This is a bug in my opinion.

MF> /m




Re: File.ReadAllText prevent write access for other processes by Peter

Peter
Wed Oct 10 10:23:26 PDT 2007

Marthin Freij wrote:
> I have noticed that File.ReadAllText prevents other processes from writing
> to the file while reading. It seems like the FileShare enum is set to Read
> rather than ReadWrite. This is a bug in my opinion.

It's not a bug. It's by design.

If you want to have more control over the file access modes, don't use
the File class. It is intended only for the basic scenarios.

Pete