Re: Trouble opening a file using BufferedStream

Tech-Archive recommends: Fix windows errors by optimizing your registry



If you want to work with text files it is better to use StreamReader :

class Program
{
static void Main(string[] args)
{
// Just make text file
using (StreamWriter writer = new StreamWriter(@"c:\test"))
{
writer.WriteLine("test1");
writer.WriteLine("test2");
}

// No problems to read text from one file
using (StreamReader reader1 = new StreamReader(@"c:\test"))
using (StreamReader reader2 = new StreamReader(@"c:\test"))
{
Console.WriteLine("r1 " + reader1.ReadLine());
Console.WriteLine("r2 " + reader2.ReadLine());

Console.WriteLine("r1 " + reader1.ReadLine());
Console.WriteLine("r2 " + reader2.ReadLine());
}
}
}

.



Relevant Pages

  • Re: Generic and COM
    ...   static void Main(stringargs) ... app will never get the memory allocation as there is no else block. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Console Application in .NET
    ... static void Main(stringargs) ... catch (Exception ex) ...
    (microsoft.public.dotnet.general)
  • Re: Invoking Console Applications Program.Main from another project
    ... static void Main(stringargs) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Dilbert C# WebService
    ... DailyDilbert.DailyDilbert wsDd = new ... static void DailyDilbertImageCompleted_Handler(object sender, DilbertADay.DailyDilbert.DailyDilbertImageCompletedEventArgs args) ...
    (microsoft.public.dotnet.languages.csharp)
  • Console Application in .NET
    ... static void Main(stringargs) ... StreamReader sr = null; ... It seems that in order to make the code compile, ...
    (microsoft.public.dotnet.general)