code_junkie

Reading and Parsing Files in .NET - Performance For Hire

Nov 12th, 2011
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. string line;
  2.  
  3. // Read the file and display it line by line.
  4. System.IO.StreamReader file =
  5. new System.IO.StreamReader("c:\test.txt");
  6.  
  7. while((line = file.ReadLine()) != null)
  8. {
  9. Console.WriteLine (line);
  10. }
  11.  
  12. file.Close();
  13.  
  14. Dim theLine as String
  15. Dim fsFile As New FileStream(inputFile, FileMode.Open) 'File Stream for the Input File
  16. Dim fsImport As New FileStream(outputFile, FileMode.OpenOrCreate) 'File Stream for the Output File
  17. Dim srFile As New StreamReader(fsFile) 'Stream Reader for Input File
  18. Dim swfile As New StreamWriter(fsImport) 'Stream Writer for Output File
  19.  
  20. Do While srFile.Peek <> -1 'Do While it's not the last line of the file
  21. theLine = srFile.ReadLine 'Read the line
  22. Messagebox.Show(theLine, "Line-by-Line!")
  23. Loop
Add Comment
Please, Sign In to add comment