Solved

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

Posted on 2004-08-16
1
241 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
ID: 11817364
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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

17 Experts available now in Live!

Get 1:1 Help Now