Share via


FileStream Constructor (String, FileMode)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Initializes a new instance of the FileStream class with the specified path and creation mode.

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

Syntax

'Declaration
Public Sub New ( _
    path As String, _
    mode As FileMode _
)
public FileStream(
    string path,
    FileMode mode
)
public:
FileStream(
    String^ path, 
    FileMode mode
)
new : 
        path:string * 
        mode:FileMode -> FileStream
public function FileStream(
    path : String, 
    mode : FileMode
)

Parameters

  • path
    Type: System. . :: . .String
    A relative or absolute path for the file that the current FileStream object will encapsulate.

Remarks

The constructor is given read/write access to the file, and it is opened sharing Read access (that is, requests to open the file for writing by this or another process will fail until the FileStream object has been closed, but read attempts will succeed). The buffer size is set to the default size of 4096 bytes (4 KB).

CanSeek is true for all FileStream objects that encapsulate files. If path indicates a device that does not support seeking, the CanSeek property on the resulting FileStream is false. For additional information, see CanSeek.

FileShare.Read is the default for those FileStream constructors without a FileShare parameter.

For constructors without a FileAccess parameter, if the mode parameter is set to Append, Write is the default access. Otherwise, the access is set to ReadWrite.

.NET Framework Security

See Also

Reference

FileStream Class

FileStream Overload

System.IO Namespace