Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c sharp how to read a text file

// To save the text as one string use 'ReadAllText()'
string text = System.IO.File.ReadAllText(@"C:filepathfile.txt");
// To save each line seperately in an array use 'ReadAllLines()'
string[] lines = System.IO.File.ReadAllLines(@"C:filepathfile.txt");
Comment

c# read all text from a file

using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
  contents = streamReader.ReadToEnd();
}
Comment

how to read a text file C#

string[] text = System.IO.File.ReadAllLines(@"C:usersusernamefilepathfile.txt");
Comment

read text c#

var text = File.ReadAllText(file, Encoding.GetEncoding(codePage));

List of codepages : https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers?redirectedfrom=MSDN
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# gzip byte array 
Csharp :: regions unity 
Csharp :: c# string equals ignore case 
Csharp :: unity key detection 
Csharp :: how to detect mouse click in c# 
Csharp :: c# textboxaccept only numbers 
Csharp :: vb.net wait 1 second 
Csharp :: unity how to convert to byte 
Csharp :: c# bytes to string 
Csharp :: unity mouse position to world 
Csharp :: c# store strings in file 
Csharp :: c# check to see if dictionary key exists 
Csharp :: check if process is open c# 
Csharp :: get unix time in seconds C# 
Csharp :: c# get full URL of page 
Csharp :: print in c# 
Csharp :: c# executable directory 
Csharp :: format phone number in c# .net 
Csharp :: C# previous method 
Csharp :: unity textmesh pro 
Csharp :: c# read file by line 
Csharp :: c# iorderedenumerable to dictionary 
Csharp :: c# date formats custom 
Csharp :: playerInputManager.JoinPlayer(....) 
Csharp :: ienumerator 
Csharp :: c# how to convert string to int 
Csharp :: C# reflection invoke static generic method 
Csharp :: how to update a project to cross target .net core 
Csharp :: minheap c# 
Csharp :: unity invisible cube 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =