Use StreamWriter to create a text file : Stream Read Write : File Stream C# Source Code


Custom Search

C# Source Code » File Stream » Stream Read Write »

 

Use StreamWriter to create a text file








    
 
using System;
using System.IO;


public class MyStreamWriterReader {
    static void Main(string[] args) {
        StreamWriter writer = new StreamWriter("reminders.txt");
        writer.WriteLine("...");
        writer.WriteLine("Don't forget these numbers:");
        for (int i = 0; i < 10; i++)
            writer.Write(i + " ");

        writer.Write(writer.NewLine);

        writer.Close();
        StreamReader sr = new StreamReader("reminders.txt");
        string input = null;
        while ((input = sr.ReadLine()) != null) {
            Console.WriteLine(input);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo File Stream
» Stream Read Write