Solved

Can two readers access the same file without an exception generated?

Posted on 2004-08-16
1
240 Views
Last Modified: 2010-04-15
I have a StreamReader and a FileStream trying to access the same file (both readers are read-only).  I get an exception--but I figured I would.  Is there a way to get around this?  
0
Comment
Question by:NTAC
1 Comment
 
LVL 9

Accepted Solution

by:
s_sansanwal earned 250 total points
Comment Utility
I tried this and able to read at same time

                  StreamReader sr = new StreamReader(@"C:\s1.txt");
                  string s = sr.ReadLine();
                  FileStream fs = File.OpenRead(@"C:\s1.txt");
                  byte[] b = new byte[1024];
                  UTF8Encoding temp = new UTF8Encoding(true);
                  while (fs.Read(b,0,b.Length) > 0)
                  {
                        string s1 = temp.GetString(b);
                  }


Just refer it for your code.

Cheers,
S Sansanwal
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Good resource for accessibility implementation 1 42
Detect file exist or not 3 76
Expando 4 33
Hide Tab Page 3 18
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now