C# Reading a File


/ Published in: C#
Save to your folder(s)

This is how I read a file using C#.


Copy this code and paste it in your HTML
  1. string DeathStarPlans = @"C:\DeathStarPlans.txt";
  2.  
  3. StringBuilder R2D2 = new StringBuilder();
  4.  
  5. using ( StreamReader PrincessLeia = new StreamReader( DeathStarPlans ) )
  6. {
  7. while ( PrincessLeia.Peek() >= 0 )
  8. {
  9. R2D2.Append( PrincessLeia.ReadLine() );
  10. }
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.