Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2007

Tip: Looking for answers? Try searching our database.

File.ReadAllText prevent write access for other processes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marthin Freij - 10 Oct 2007 12:44 GMT
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
Vadym Stetsiak - 10 Oct 2007 13:23 GMT
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
Peter Duniho - 10 Oct 2007 18:23 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.