Solved

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

Posted on 2004-08-16
1
243 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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