Answers for "read file c#"

C#
25

c sharp how to read a text file

// To save the text as one string use 'ReadAllText()'
string text = System.IO.File.ReadAllText(@"C:\filepath\file.txt");
// To save each line seperately in an array use 'ReadAllLines()'
string[] lines = System.IO.File.ReadAllLines(@"C:\filepath\file.txt");
Posted by: Guest on February-22-2020
6

read file c#

string text = File.ReadAllText(@"c:\file.txt", Encoding.UTF8);
Posted by: Guest on November-18-2020
6

c# read all text from a file

using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
  contents = streamReader.ReadToEnd();
}
Posted by: Guest on April-22-2020
0

c# read file store in String

using System;
using System.IO;
 
public class Example
{
    public static void Main()
    {
        string fileName = @"C:\some\path\file.txt";
 
        string text = File.ReadAllText(fileName);
        Console.WriteLine(text);
    }
}
 
Posted by: Guest on September-21-2020
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
0

c# read from file

string[] lines = File.ReadAllLines(@"c:\file.txt", Encoding.UTF8);
Posted by: Guest on September-21-2021

C# Answers by Framework

Browse Popular Code Answers by Language