FileStream.WriteByte : FileStream « System.IO « C# / C Sharp by API






FileStream.WriteByte

 
using System;
using System.IO;
class WriteToFile {
  public static void Main(string[] args) {
    FileStream fout;

    try {
      fout = new FileStream("test.txt", FileMode.Create);
    } catch(IOException exc) {
      Console.WriteLine(exc.Message + "\nError Opening Output File");
      return;
    }

    // Write the alphabet to the file.
    try {
      for(char c = 'A'; c <= 'Z'; c++)
        fout.WriteByte((byte) c);
    } catch(IOException exc) {
      Console.WriteLine(exc.Message + "File Error");
    }

    fout.Close();
  }
}

   
  








Related examples in the same category

1.new FileStream(String fileName, FileMode.Open)
2.new FileStream("soaptest.xml", FileMode.Create, FileAccess.ReadWrite)
3.FileStream.Position
4.FileStream.Read
5.FileStream.ReadByte
6.FileStream.SetLength
7.FileStream.Write