Answers for "streamreader c#"

C#
3

c# read file stream

using System;
using System.IO;
using System.Text;

namespace StreamReaderReadToEnd
{
    class Program
    {
        static void Main(string[] args)
        {
            var path = @"C:\Users\Jano\Documents\thermopylae.txt";

            using var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            using var sr = new StreamReader(fs, Encoding.UTF8);
            
            string content = sr.ReadToEnd();

            Console.WriteLine(content);
        }
    }
}
Posted by: Guest on February-17-2020
3

c# streamreader

// The StreamReader are using the Namespaces: System and system.IO

using (StreamReader sr = new StreamReader("TestFile.txt"))
{
  string line;
  while ((line = sr.ReadLine()) != null)
  {
    Console.WriteLine(line);
  }
}
Posted by: Guest on March-04-2021
1

streamreader c#

using System;
using System.IO;

class Test
{
    public static void Main()
    {
        try
        {
            using (StreamReader sr = new StreamReader("File1"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("The file could not be read:");
            Console.WriteLine(e.Message);
        }
    }
}
Posted by: Guest on September-02-2021
2

how to read a text file C#

string[] text = System.IO.File.ReadAllLines(@"C:\users\username\filepath\file.txt");
Posted by: Guest on October-06-2020
1

C# using StreamReader

using System.IO; // <- This is the class for StreamReader
Posted by: Guest on January-25-2021

C# Answers by Framework

Browse Popular Code Answers by Language