Complete-Reference-Vb Net 40
Complete-Reference-Vb Net 40
End Get
End Property
C:\
The following example tests to see if a logical root exists in a path string. It returns False when the FilePath
property passes "indexwork\noisefile.txt" to the IsPathRooted method.
Remember that Path is not privy to exactly what's cooking on the hard disks or devices, volatile or built of
silicone and metal. Just because a drive and file path check though the Path's string gauntlet does not mean
the actual drive, computer, and network actually exist at the time the path checks out.
File Enumerations
Among the parameters required by various methods for file operations are certain values that are represented
by a collection of enumeration classes. These classes include constants for file access, synchronous or
asynchronous processing, and file attributes. Table 15−11 lists the file enumeration classes.
Note These enumerations can apply to FileInfo and FileStream classes as well, so get used to them now.
FileAccess
Various file−handling methods require you to specify the level of file access enjoyed by the user or process
accessing the file. The default file access level is full read and write capability on a file. A FlagsAttribute
attribute decorates the class (refer to Chapter 8) so that the CLR can evaluate bitwise combinations of the
members of the enumeration. Table 15−12 lists the three FileAccess attributes.
Here is an example that grants read−only access to a file. This allows it to be opened by the File operation
while someone else is using the file, but only allows the other, latter users to read the file. They cannot write
to it until they get the chance to open the file with write access, as demonstrated in the following code:
Enumeration Purpose
FileAccess Read and write access to a file
FileShare Level of access permitted for a file that is already in use
FileMode Synchronous or asynchronous access to the file in use
Table 15−12: Constants for the FileAccess Attributes Parameter
524