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

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# verify in class exist in list 
Csharp :: c# delete files in directory and subdirectories 
Csharp :: how to filter a datatable in c# 
Csharp :: how to write coroutine in unity 
Csharp :: linq when name then orderby 
Csharp :: check if palindrome recursion in c# 
Csharp :: dotween sequence 
Csharp :: c# loops 
Csharp :: how to insert into a list c# 
Csharp :: And this is how can you deserialize your XML file in your C# code: 
Csharp :: c# convert to nullable datetime 
Csharp :: c# itext 7 PdfDocument from byte array 
Csharp :: the same schemaid is already used for type swagger 
Csharp :: how to iterate between hour range in c# 
Csharp :: c# online compiler 
Csharp :: dataannotations datetime range 
Csharp :: how to set the value of a textbox textmode=date asp.net c# 
Csharp :: how read excel data in c# 
Csharp :: c# get assembly directory 
Csharp :: c# list item not in another list 
Csharp :: ? operator 
Csharp :: c# dictionary with dictionary as value 
Csharp :: c# goto statement 
Csharp :: c# object is in object list 
Csharp :: fluent api 
Csharp :: C# linq mselect 
Csharp :: loop for specific time c# 
Csharp :: c# xmldocument from file 
Csharp :: global exception handler c# 
Csharp :: c# centos Regex Username 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =