The FileSystemObject Object
The FileSystemObject will allow the programmer
to
- Get and manipulate information about all of the drives on
the server, both local and remote.
- Read and change information about the file system(folders,
etc.)
- Modify information about the files in the server's file system.
The FilesSystemObject Object Properties
The FileSytemObject object has only one property, drives, which
allows us to retrieve a list of all the valid drives on the Machine.
Drives: Returns a collection of Drive objects that are available
from the local machine. This includes mapped network drives.
The FileSystemObject's Methods
The FileSystemObject object provides a range of methods for manipulating
the subsidiary objects like Drive, Folder and File. It also provides
2 methods for working with TextStream objects: CreateTextFile and
OpenTextFile.
Methods working with Drives
Method |
Description |
| DriveExists(drive_path) |
Returns true if the drive specified in drive_path exists, or
False if not. |
| GetDrive(drive_path) |
Returns a Drive object corresponding to the drive specified
in drive_path. |
| GetDriveName(drive_path) |
Returns the name of the drive specified in drive_path as a
string. drive_path must be an absolute path to a file or folder,
or just drive letter such as "c:" |
Methods for Working with Folders
Method |
Description |
BuildPath(path, name) |
Adds the file or folder specified in name
to the existing path, adding a path separator character ('\')
if required. |
CopyFolder(source,destination,
overwrite) |
Copies the folder or folders specified in
source(wildcards can be included) to the folder destination,
including all the files in source folders. |
CreateFolder(foldername) |
Creates a new folder which has the path and
name specified in foldername. An error occurs if the specified
folder already exists. |
DeleteFolder(folderspec,force) |
Deletes the folder or folders specified in
folderspec(could include wildcards) together with all their
contents |
FolderExists(folderspec) |
Returns True if the folder specified in folderspec
exists, or false if not. |
GetAbsolutePathName(pathspec) |
Returns an absolute full path for the folder specified by pathspec. |
GetFolder(folderspec) |
Returns a Folder object corresponding to the folder specified
in folderspec. |
GetParentFolderName(pathspec) |
Returns the name of the parent folder of the file or folder
specified in pathspec. |
GetSpecialFolder(folderspec) |
Returns a Folder object corresponding to one of the special
Windows folders. The permissible values for folderspec are WindowsFolder(0),
SystemFolder(1) and TemporaryFolder(2). |
MoveFolder(source,destination) |
Moves the folder or folders named in source to the folder named
in destination. |
Methods for Working with Files:
Method |
Description |
CopyFile(source, destination,
overwrite) |
Copies the file or files named in source
to the folder named in destination. The default for overwrite
is true. If overwrite is set to false and destination file
already exists, an error will occur. |
CreateTextFile(filename,overwrite,
unicode) |
Creates a new text file on disk with the
specified filename, and returns a TextStream object that refers
to it. The default value of overwrite is False. If unicode
parameter is set to True, the content of the file will be stored
as Unicode text. The default for unicode is False.
DeleteFile(filespec,force): Deletes the file or files named in filespec. IF optional
force parameter is set to True, the files will be deleted even if the Read-only
attribute is set. The default for force is False. |
FileXistes(filespec) |
Returns true if the file specified in filespec
exists, or False if not. The filespec could be an absolute
or relative file path. |
GetBaseName(filespec) |
Returns just the name of file named in filespec,
with the path and file extension removed. |
GetExtensionName(filespec) |
Returns just the file extension of file specified
in filespec
, i.e. with the path and file name removed. |
GetFile(filespec) |
Returns a File object corresponding to the
file specified in filespec. This can be a relative or absolute
path to the required file. |
GeFileName(pathspec) |
REturns the name part of the path and filename
specified in pathspec, or the last folder name of there is
no file name .Doesn't check for existence of the file or folder. |
GetTempName(filespec) |
Returns a randomly generated file name, which
can be used for performing operations that require a temporary
file or folder. |
OpenTextFile(filename,iomode,create,format) |
Creates a file named filename, or pens an existing file named
filename, and returns a TextStream object that refers to it.
The filename parameter can contain an absolute or relative path.
The iomode could be ForReading(1)--default), ForWriting(2), and
ForAppending(8).
|
MoveFile(source,destination) |
Moves the file or files specified in source
to the folder specified in destination. |
If the create is set to True when writing or appending to a file
that doesn't exist, a new file will be created. The default value
of create is False. The format parameters specifies the format of
the data bo be read from or written to the file. Permissible values
are TristateFalse(0--default) to open it a s ASCII, TristateTrue(-1)
to open it as Unicode, and TristateUseDefault(-2) to open it using
the system default format.
|