FileMode Enumeration

FileMode Enumeration

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Specifies how the operating system should open a file.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

No code example is currently available or this language may not be supported.

Member nameDescription
AppendOpens the file if it exists and seeks to the end of the file, or creates a new file. Append can only be used in conjunction with Write. Attempting to seek to a position before the end of the file will throw an IOException and any attempt to read fails and throws an NotSupportedException.
CreateSpecifies that the operating system should create a new file. If the file already exists, it will be overwritten. Create is equivalent to requesting that if the file does not exist, use CreateNew; otherwise, use Truncate.
CreateNewSpecifies that the operating system should create a new file.
OpenSpecifies that the operating system should open an existing file. The ability to open the file is dependent on the value specified by FileAccess. A System.IO::FileNotFoundException is thrown if the file does not exist.
OpenOrCreateSpecifies that the operating system should open a file if it exists; otherwise, a new file should be created.
TruncateSpecifies that the operating system should open an existing file. Once opened, the file should be truncated so that its size is zero bytes.

Specify a FileMode parameter IsolatedStorageFileStream constructors.

FileMode parameters control whether a file is overwritten, created, opened, or some combination thereof. Use Open to open an existing file. To append to a file, use Append. To truncate a file or create a file if it doesn't exist, use Create.

The following example opens an existing file. This example is part of a larger example provided for the IsolatedStorageFile class.

No code example is currently available or this language may not be supported.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft