FileOptions Enumeration


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Represents advanced options for creating a FileStream object.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

Public Enumeration FileOptions

Member nameDescription

Indicates that a file can be used for asynchronous reading and writing.


Indicates that a file is automatically deleted when it is no longer in use.


Indicates that a file is encrypted and can be decrypted only by using the same user account used for encryption.


Indicates that no additional options should be used when creating a FileStream object.


Indicates that the file is accessed randomly. The system can use this as a hint to optimize file caching.


Indicates that the file is to be accessed sequentially from beginning to end. The system can use this as a hint to optimize file caching. If an application moves the file pointer for random access, optimum caching may not occur; however, correct operation is still guaranteed.


Indicates that the system should write through any intermediate cache and go directly to disk.

The following example shows how to use the Asynchronous value when creating a file stream.

Imports System.IO
Imports System.Text

Module Module1

    Sub Main()
    End Sub

    Async Sub WriteToFile()
        Dim bytesToWrite = Encoding.Unicode.GetBytes("example text to write")
        Using createdFile As FileStream = File.Create("c:/Temp/testfile.txt", 4096, FileOptions.Asynchronous)
            Await createdFile.WriteAsync(bytesToWrite, 0, bytesToWrite.Length)
        End Using
    End Sub

End Module

Universal Windows Platform
Available since 10
.NET Framework
Available since 2.0
Return to top