C# FileStream SetLength

Description

FileStream SetLength Sets the length of this stream to the given value.

Syntax

FileStream.SetLength has the following syntax.


public override void SetLength(
  long value
)

Parameters

FileStream.SetLength has the following parameters.

  • value - The new length of the stream.

Returns

FileStream.SetLength method returns

Example

Sets the length of this stream to the given value.


using System;/*from  w ww  .  j  a  v  a 2s .c  om*/
using System.IO;

class TestRW 
{
    public static void Main(String[] args)
    {
        FileStream fs = new FileStream("MyFile.txt", FileMode.OpenOrCreate, FileAccess.Read);
        fs.SetLength(100);
    }
}




















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter