Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7594497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:25:53+00:00 2026-05-30T21:25:53+00:00

I am writing a messaging app in C# that runs on a shared file

  • 0

I am writing a messaging app in C# that runs on a shared file server on a network. The program works by multiple users running the program which accesses a file that is shared between the multiple computers. Hence, I need to use the StreamReader/StreamWriter to access the file with multiple programs at once (EDIT: I now know this isn’t a good way to do it, but it’s what I needed at the time). So how may I access a single file with multiple programs without getting errors about the file being in use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:25:54+00:00Added an answer on May 30, 2026 at 9:25 pm

    I think your approach will lead to problems in the future. I’d consider leveraging Redis pub/sub if I were you.

    But, since you asked… (I wrote a blog post on this: http://procbits.com/2011/02/18/streamwriter-share-read-access-in-another-process/ )

    Generator of chat data:

    var fs = File.Open(@"C:\messages.txt", FileMode.Append, FileAccess.Write, FileShare.Read);
    var sw = new StreamWriter(fs);
    sw.AutoFlush = true;
    

    Somewhere else in your app or another app…

    Readers of chat data:

    var fs = File.Open(@"C:\messages.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
    var sr = new StreamReader(fs);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Java ME app that will use privileged operations such as messaging.
I'm writing an Android app which will be making use of the cloud-2-device messaging
I'm writing a flex application that polls an xml file on the server to
I'm writing a simple messaging program, where there is a table of messages, which
I've a JMS messaging app thats reading and writing to MQ queues. The message
I'm writing a messaging layer that should handle communication with a third party API.
I've been writing a small Facebook app which uses the unified_thread table using FQL.
We're using a 3rd party XML messaging service that requires an embedded PDF file
I am writing a little Shoes app that requires a library I wrote with
I'm writing an instant messaging server in C# for learning purposes. My question is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.