Gemstone IO Library
Show/Hide TOC

# CachedFileStream(String, FileMode, FileAccess, FileShare, Int32) Constructor

Initializes a new instance of the FileStream class with the specified path, creation mode, read/write and sharing permission, the access other FileStreams can have to the same file, the buffer size, and additional file options.

## Definition

Namespace: IO
Assembly: Gemstone.IO (in Gemstone.IO.dll) Version: 1.0.154 -- Release Build+690e585b1010bc9bfdc9c11ba61c54180863b212
C#
View Source Request Example

    public CachedFileStream(
    	string path,
    	FileMode mode,
    	FileAccess access,
    	FileShare share,
    	int blockSize
    )

VB
View Source Request Example

    Public Sub New (
    	path As String,
    	mode As FileMode,
    	access As FileAccess,
    	share As FileShare,
    	blockSize As Integer
    )

C++
View Source Request Example

    public:
    CachedFileStream(
    	String^ path,
    	FileMode mode,
    	FileAccess access,
    	FileShare share,
    	int blockSize
    )

JavaScript
View Source Request Example

    Gemstone.IO.CachedFileStream = function(path, mode, access, share, blockSize);

#### Parameters

path String
  A relative or absolute path for the file that the current FileStream object will encapsulate.
mode FileMode
  A constant that determines how to open or create the file.
access FileAccess
  A constant that determines how the file can be accessed by the FileStream object. This gets the CanRead and CanWrite properties of the FileStream object. CanSeek is true if path specifies a disk file.
share FileShare
  A constant that determines how the file will be shared by processes.
blockSize Int32
  A positive Int32 value greater than 0 indicating the block size. For blockSize values between one and eight, the actual block size is set to eight bytes.

## Exceptions

ArgumentNullException | path is null.
ArgumentException | path is an empty string (""), contains only white space, or contains one or more invalid characters. -or-path refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.
NotSupportedException | path refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.
ArgumentOutOfRangeException | blockSize is negative or zero.-or- mode, access, or share contain an invalid value.
FileNotFoundException | The file cannot be found, such as when mode is FileMode.Truncate or FileMode.Open, and the file specified by path does not exist. The file must already exist in these modes.
IOException | An I/O error, such as specifying FileMode.CreateNew when the file specified by path already exists, occurred.-or-The stream has been closed.
SecurityException | The caller does not have the required permission.
DirectoryNotFoundException | The specified path is invalid, such as being on an unmapped drive.
UnauthorizedAccessException | The access requested is not permitted by the operating system for the specified path, such as when access is Write or ReadWrite and the file or directory is set for read-only access.
PathTooLongException | The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.

## See Also

#### Reference

CachedFileStream Class
CachedFileStream Overload
IO