System.IO.FileMode Enum

public enum FileMode

Base Types

Object
  ValueType
    Enum
      FileMode

Assembly

mscorlib

Library

BCL

Summary

Specifies how the operating system opens a file.

Description

FileMode values specify whether a file is created if one does not exist, and determine whether the contents of existing files are retained or overwritten.

See Also

System.IO Namespace

Members

FileMode Fields

FileMode.Append Field
FileMode.Create Field
FileMode.CreateNew Field
FileMode.Open Field
FileMode.OpenOrCreate Field
FileMode.Truncate Field
FileMode.value__ Field


FileMode.Append Field

Append = 6;

Summary

Requests a file be opened. If the file exists, its contents are preserved. This value is valid only for System.IO.FileAccess.Write access. Attempts to read from a file opened with Append cause an exception.

See Also

System.IO.FileMode Enum, System.IO Namespace

FileMode.Create Field

Create = 2;

Summary

Requests a new file be created if it does not exist. The file contents are overwritten if it does exist. This value is equivalent to requesting that if the file does not exist, use System.IO.FileMode.CreateNew; otherwise, use System.IO.FileMode.Truncate.

See Also

System.IO.FileMode Enum, System.IO Namespace

FileMode.CreateNew Field

CreateNew = 1;

Summary

Requests a new file be created. An exception is thrown if the file already exists.

See Also

System.IO.FileMode Enum, System.IO Namespace

FileMode.Open Field

Open = 3;

Summary

Requests an existing file be opened. An exception is thrown if the file does not exist.

See Also

System.IO.FileMode Enum, System.IO Namespace

FileMode.OpenOrCreate Field

OpenOrCreate = 4;

Summary

Requests a file be opened. The file is created if it does not exist.

See Also

System.IO.FileMode Enum, System.IO Namespace

FileMode.Truncate Field

Truncate = 5;

Summary

Requests an existing file be opened; existing contents are deleted. This value is valid only for System.IO.FileAccess.Write access. Attempts to read from a file opened with Truncate cause an exception.

See Also

System.IO.FileMode Enum, System.IO Namespace

FileMode.value__ Field

value__;

See Also

System.IO.FileMode Enum, System.IO Namespace