Solved

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

Posted on 2004-08-16
1
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding items to a C# list incrementally 5 82
c# deserialize JSON from web service using JsonConvert 9 61
Windows Universal App 22 63
How do I "share" on social sites? 2 39
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…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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