473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 7422
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.