csharp read file stream

Code Example - csharp read file stream

                
                        //this will get a string with all the text from the file
var fileText = File.ReadAllText(@"path\to\my\file.txt");

//this will get all of the lines of the file as an string[]
var fileLines = File.ReadAllLines(@"path\to\my\file.txt");
                    
                
 

return stream from file csharp

                        
                                private void Test()
{            
    System.IO.MemoryStream data = new System.IO.MemoryStream(TestStream());

    byte[] buf = new byte[data.Length];
    data.Read(buf, 0, buf.Length);                       
}
                            
                        
 

Related code examples