473,473 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

filestream append and read access at same time?

Bob
Hi,
Is there any setting that I can use to allow the same file to be open
in a filestream in append mode with one process and read in another.
I can see why concurrent appends or write modes wouldn't work but it
seems like maybe a read could coexist with append?

Thanks,
Bob

Nov 2 '07 #1
5 7425
On 2007-11-01 17:35:56 -0700, Bob <bs********@yahoo.comsaid:
Hi,
Is there any setting that I can use to allow the same file to be open
in a filestream in append mode with one process and read in another.
I can see why concurrent appends or write modes wouldn't work but it
seems like maybe a read could coexist with append?
Take a look at the FileStream constructors that include a FileShare
enumeration value as a parameter.

Pete

Nov 2 '07 #2
Sample below for multi acces read and write

i have several multi threaded services and also reader of activity in this
log....

hope this helps

analizer1

if (!File.Exists(LogName.FullName))

{

sw = new FileStream(this.LogName.FullName, FileMode.Create,
FileAccess.ReadWrite, FileShare.ReadWrite);

}

else

{

sw = new FileStream(this.LogName.FullName, FileMode.Open,
FileAccess.ReadWrite, FileShare.ReadWrite);

}

"Bob" <bs********@yahoo.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Hi,
Is there any setting that I can use to allow the same file to be open
in a filestream in append mode with one process and read in another.
I can see why concurrent appends or write modes wouldn't work but it
seems like maybe a read could coexist with append?

Thanks,
Bob

Nov 2 '07 #3
On 2007-11-01 19:29:56 -0700, "Analizer1" <ve***********@yahoo.comsaid:
Sample below for multi acces read and write
Note that there is a FileMode.CreateOrOpen enumeration value. There's
no need to check for file existence before creating the FileStream; you
can use the same constructor for both scenarios.

Pete

Nov 2 '07 #4
Bob
On Nov 1, 10:10 pm, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.comwrote:
On 2007-11-01 19:29:56 -0700, "Analizer1" <vettes_n_j...@yahoo.comsaid:
Sample below for multi acces read and write

Note that there is a FileMode.CreateOrOpen enumeration value. There's
no need to check for file existence before creating theFileStream; you
can use the same constructor for both scenarios.

Pete
Thanks very much. It seems like I had to change a setting from
FileAccess.Read to FileAccess.ReadWrite which seems odd considering I
would think the former would be more restrictive. Thanks again.

Nov 2 '07 #5
On 2007-11-01 22:29:57 -0700, Bob <bs********@yahoo.comsaid:
Thanks very much. It seems like I had to change a setting from
FileAccess.Read to FileAccess.ReadWrite which seems odd considering I
would think the former would be more restrictive. Thanks again.
I'm not sure what you mean. The FileAccess determines how your process
opens the file. The FileShare determines what other processes can do
with a file you've opened.

You would certainly need to open the file with write access if you
expect to be able to write to it, thus the need for
FileAccess.ReadWrite.

Pete

Nov 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Martyn Wynne | last post by:
Hi, Can anyone please tell me if there is any reason why when i am streaming from a webrequest (decompressing on route) to a file on the hard drive, i would be getting an exception of Filestream...
9
by: Tom | last post by:
I am working with the this object as oppose to the StreamReader object becuase I need to access a file (to find the contents) while an external application is updating the file. When I was...
11
by: Dorsa | last post by:
HI, Could you please tell me the error in here. I am trying to open an XML file from a link. Response.Clear() Response.Expires = 0 Response.BufferOutput = False Response.ContentType =...
0
by: lh | last post by:
The following method only works when i give the ASP.net account full permissions on the directory. It doesn't work when i give the directory Modify, Read &Execute, List Folder Contents, Read, and...
0
by: JeffW | last post by:
Researched this, but none of the proposed solutions are working for me. Am hoping for some insight. Am trying to open a binary file that exists on a shared drive for reading. Code lives inside...
9
by: Tim_Mac | last post by:
hi, i'm not sure if i have chosen the best approach, but it seemed quite good to me. i have a collection class, containing business objects. the collection class is static and remains in-memory...
6
by: bonk | last post by:
I am trying to create a stream that writes text to a file and: - automatically creates a new file once the current file exceeds a certain size - makes it possible to be used by multiple threads...
6
by: andycee | last post by:
Hi, I'm having FileStream.Write behave rather oddly. The code below should take file a.txt and append it to file b.txt : Dim buffer As Byte() Dim bytesRead As Integer ...
2
by: Radek | last post by:
Hi, I have the following problem with FileStream. In this line: FileStream file = new FileStream(filePath, FileMode.Append); there is an exception FileNotFoundException. But for sure path and...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.