NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

FileStream Constructor (String, FileMode, FileAccess, FileShare)

Initializes a new instance of the FileStream object with the specified path, creation mode, read/write, and sharing permission.

[Visual Basic]
Overloads Public Sub New( _
   ByVal path As String, _
   ByVal mode As FileMode, _
   ByVal access As FileAccess, _
   ByVal share As FileShare _
)
[C#]
public FileStream(
   string path,
   FileMode mode,
   FileAccess access,
   FileShare share
);
[C++]
public: FileStream(
   String* path,
   FileMode mode,
   FileAccess access,
   FileShare share
);
[JScript]
public function FileStream(
   path : String,
   mode : FileMode,
   access : FileAccess,
   share : FileShare
);

Parameters

path
A relative or absolute path for the file that the current FileStream object will encapsulate.
mode
A FileMode constant that determines how the file is opened or created.
access
A FileAccess constant that determines how the file may be accessed by the FileStream object. This sets the CanRead and CanWrite properties of the FileStream object. CanSeek is set to true if path specifies a disk file.
share
A FileShare constant that determines how the file will be shared by processes.

Exceptions

Exception Type Condition
ArgumentNullException path is null.
ArgumentException mode is not a field of FileMode.
ArgumentException access is not a field of FileAccess.
ArgumentException share is not a field of FileShare.
ArgumentException path is an empty string ("").
SecurityException The caller does not have the required FileIOPermission.
FileNotFoundException The file cannot be found.
IOException An I/O error occurs.

Requirements

NGWS Runtime Security:

FileIOPermissionAccess Write flag required by FileMode.Create or FileMode.CreateNew, by FileMode.OpenOrCreate when access is FileAccess.ReadWrite and the file does not exist, or when access is FileAccess.Read, and by FileMode.Truncate, FileAccess.Write, and FileAccess.ReadWrite.
FileIOPermissionAccess Read flag required by FileMode.Open, FileAccess.Read, and FileAccess.ReadWrite.
FileIOPermissionAccess Append flag required by FileMode.Create or FileMode.CreateNew, by FileMode.OpenOrCreate when access is FileAccess.ReadWrite and the file does not yet exist, and byFileMode.OpenOrCreate if the file does not yet exist.

See Also

FileStream Class | FileStream Members | System.IO Namespace | FileStream Constructor Overload List