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






FileStream.SetLength

  
using System;
using System.IO;

    public class StrmWrtr
    {
        static public void Main (string [] args)
        {
            FileStream strm;
            StreamWriter writer;
            strm = new FileStream ("text.txt", FileMode.OpenOrCreate, FileAccess.Write);
            writer = new StreamWriter (strm);
            strm.SetLength (0);
            while (true)
            {
                 string str = Console.ReadLine ();
                 if (str.Length == 0)
                     break;
                 writer.WriteLine (str);
            }
            writer.Close ();
            strm.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.Write
7.FileStream.WriteByte