StreamWriter.Write : StreamWriter « System.IO « C# / C Sharp by API






StreamWriter.Write

  
using System;
using System.IO;
public class MainClass {
    public static void Main() {

        FileStream fs2 = File.Create("Bar.txt");

        StreamWriter w2 = new StreamWriter(fs2);
        w2.Write("Goodbye Mars");
        w2.Close();

        fs2 = File.Open("Bar.txt", FileMode.Open, FileAccess.Read, FileShare.None);
        StreamReader r2 = new StreamReader(fs2);
        String t;
        while ((t = r2.ReadLine()) != null) {
            Console.WriteLine(t);
        }
        w2.Close();
        fs2.Close();

    }
}

   
    
  








Related examples in the same category

1.new StreamWriter
2.StreamWriter.Flush
3.StreamWriter.WriteLine