Share via


ReparsePointAware.OpenFile(String, FileMode, FileAccess, FileShare) Method

Definition

Opens a System.IO.FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. If the file's canonical path contains Windows Reparse Points, UnauthorizedAccessException is thrown. OpenFile will pin the directory first before doing any file operations. If pinning the directory fails or the directory is a ReparsePoint, UnauthorizedAccessException will be thrown.

public static System.IO.FileStream OpenFile (string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share = System.IO.FileShare.None);
static member OpenFile : string * System.IO.FileMode * System.IO.FileAccess * System.IO.FileShare -> System.IO.FileStream
Public Shared Function OpenFile (path As String, mode As FileMode, access As FileAccess, Optional share As FileShare = System.IO.FileShare.None) As FileStream

Parameters

path
String

Full path to the target file.

mode
FileMode

FileMode of the operation. Supports Create, CreateNew, Open or OpenOrCreate.

access
FileAccess

Requested FileAccess permissions. Refer to NativeFlagsEx for what flags are supported.

share
FileShare

Requested FileShare access. Refer to NativeFlagsEx for what flags are supported.

Returns

A file stream to the file being opened. Caller is responsible for disposing of the file stream when operations are complete.

Exceptions

The path contains Windows Reparse Points or otherwise cannot be accessed.

Applies to