complete-reference-vb_net_43
complete-reference-vb_net_43
Note If a file is already open when you try to open it using one of the Read, Write, or None flags, the
operation will fail. You can only gain access to the file once the current owner has closed it. And
even if the file is closed and you pass one of the above flags, you may still need additional
permissions to access it.
FileShare
The constants exposed in the FileShare enumeration map to constants that let you specify to the file system
exactly how a file should be opened when it opens it. These constants are typically passed to the Open
methods of File and FileInfo and in the constructors of FileStream (discussed later in this chapter) and the
IsolateStorageFileStream. Table 15−15 lists the constants of this enumeration.
This section demonstrates how to create and work with files. In the example code, I have created a class with
various methods that call the File class's static methods. I then allow other objects to delegate to this wrapper
or bridge the objects for file operations.
Member Purpose
Inheritable Allows the file handle to be inherited by child processes. This feature is apparently
not directly supported by the Win32 API.
None Rebukes attempts to share access to a file. Any request to open the file by the current
process or any another process fails until the file is closed.
Read Allows subsequent opening of the file for reading
ReadWrite Allows subsequent opening of the file for reading or writing
Write Allows subsequent opening of the file for writing
527