Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
FileOptions Enumeration

FileOptions Enumeration

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)

[<SerializableAttribute>]
[<FlagsAttribute>]
[<ComVisibleAttribute(true)>]
type FileOptions

Member nameDescription
AsynchronousIndicates that a file can be used for asynchronous reading and writing.
DeleteOnCloseIndicates that a file is automatically deleted when it is no longer in use.
EncryptedIndicates that a file is encrypted and can be decrypted only by using the same user account used for encryption.
NoneIndicates that no additional options should be used when creating a FileStream object.
RandomAccessIndicates that the file is accessed randomly. The system can use this as a hint to optimize file caching.
SequentialScanIndicates 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.

Specifying this flag can increase performance for applications that read large files using sequential access. Performance gains can be even more noticeable for applications that read large files mostly sequentially, but occasionally skip over small ranges of bytes.

WriteThroughIndicates 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.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft