csharp read from file

Code Example - csharp read from file

                
                        string[] lines = File.ReadAllLines(@"c:\file.txt", Encoding.UTF8);
                    
                
 

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");
                            
                        
 

how to read a text file csharp

                        
                                string[] text = System.IO.File.ReadAllLines(@"C:\users\username\filepath\file.txt");
                            
                        
 

read file csharp

                        
                                string text = File.ReadAllText(@"c:\file.txt", Encoding.UTF8);
                            
                        
 

csharp read all text from a file

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