0% found this document useful (0 votes)
13 views1 page

Complete-Reference-Vb Net 40

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Complete-Reference-Vb Net 40

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

File Enumerations

End Get
End Property

The PathRoot information returned is

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.

Public ReadOnly Property CheckRooted() As Boolean


Get
Return PathChecker.IsPathRooted(FilePath)
End Get
End Property

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:

Dim noisefile As New FileStream(filePath, FileMode.Open, _


FileAccess.Read, FileShare.Read)

Table 15−11: File Enumeration Classes

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

You might also like