Web Hosting Canada
Web Hosting Canada  
ASP.NET Support  
Call Toll-Free 1-866-421-8886  
 ASP Hosting
DEVELOPER RESOURCES


 • 
Technetex Canada


 • 
Support Website


 • 
Forums


 • 
Dev Resources


ASP


 • 
ASP Reference Index


 • 
Built-in ASP Objects


 • 
Other ASP Objects


 • 
VBScript Reference


 • 
Links


 

   
 
Other ASP Objects
 

At-a-glance information about other ASP objects. These objects are the File System object, the File object, the Folder object, the Drive object, and the TextStream object. For each object, the properties, methods, collections, and events are discussed.

File System Object

The File System object is used to access the files and folders of the server.

Methods

BuildPath(path, name) appends name onto path, fixing the path separator if necessary.

CopyFile source, destination, overwrite copies the file specified by source to destination. If there is already a file by the same name in the destination, and overwrite is True, the file is overwritten. If it is false, the file will not be overwritten.

CopyFolder source, destination, overwrite copies the folder specified by source to destination. If there is already a folder by the same name in the destination, and overwrite is True, the file is overwritten. If it is false, the file will not be overwritten.

CreateFolder(foldername) creates a folder.

CreateTextFile(filename, overwrite, unicode) creates a text file and returns the TextStream object for it. overwrite is an optional Boolean value that indicates if the file should be overwritten, if it already exists. True indicates the file should be overwritten, False indicates it should not. The default value is False. unicode is an optional Boolean value that indicates whether the file is created as Unicode or ASCII. True indicates Unicode, False indicates ASCII. The default is False.

DeleteFile(path, force) deletes the file(s) specified by path. path may contain a wildcard character at the end. force is an optional parameter that is set to True to force read-only files to be deleted.

DeleteFolder(path, force) deletes the folder(s) specified by path and their contents. path may contain a wildcard character at the end. force is an optional parameter that is set to True to force read-only folders to be deleted.

DriveExists(path) returns a Boolean value indicating whether the drive specified by path exists.

FileExists(path) returns a Boolean value indicating whether the file specified by path exists.

FolderExists(path) returns a Boolean value indicating whether the folder specified by path exists.

GetAbsolutePathName(pathspec) returns a complete path given a specification. For example, if pathspec is "c:", it returns the full path to the current directory on the c drive. If it is "c:..", it would return the parent of the current folder.

GetBaseName(path) returns the base (no extension) of the filename pointed to by path.

GetDrive(path) returns the Drive object for the drive containing path.

GetDriveName(path) returns a string containing the name of the drive for path.

GetExtensionName(path) returns the extension of the file specified by path.

GetFile(path) returns the File object corresponding to the file specified by path.

GetFileName(path) returns the last filename or folder of path. For example, GetFileName("c:\Inetpub\wwwroot\default.asp") would return "default.asp".

GetFolder(path) returns the Folder object corresponding to the folder specified by path.

GetParentFolderName(path) returns a string containing the parent folder of the file or folder specified by path.

GetSpecialFolder(spec) returns the path to the specified special folder. spec can have one of three values: WindowsFolder, SystemFolder, TemporaryFolder. These constants have the values 0, 1, 2 respectively. With these, you can get the path to the server's Windows directory, system directory, or temporary directory.

MoveFile source, destination moves the file specified by source to destination.

MoveFolder source, destination moves the folder specified by source to destination.

OpenTextFile(filename, iomode, create, format) returns an instance of the TextStream object corresponding to filename. iomode specifies whether the file should be opened for reading (1), for writing (2). or for appending (8). create indicates whether to create the file if it does not already exist. If format is -1, it opens the file as Unicode. If it is 0, it opens it as ASCII. If format is -2, the file is opened according to the system default.

Collections

Drives contains all the drive objects available on the machine.

Top
File Object

The File object is used to represent a single file (usually a text file) on the server.

Properties

Attributes is used to set and return some of the special attributes of the file.

DateCreated returns the date and time that the file was created. This is a read-only property.

DateLastAccessed returns the date and time the file was last accessed. This is a read-only property.

DateLastModified returns the date and time the file was last modified. This is a read-only property.

Drive returns the letter of the drive the file is on. This is a read-only property.

Name is used to set or return the name of the file.

ParentFolder returns an instance of the folder object corresponding to the parent folder of the file.

Path returns the path for the file, including the filename.

ShortName returns the version of the filename used by programs that do not support long filenames. This name consists of no more than eight characters, followed by a ".", followed by no more than three characters.

ShortPath returns the path to the file as it is seen by programs that do not support long filenames.

Size returns the size, in bytes, of the file.

Type returns information that is known about the type of the file. For example, if the file is a ".txt" file, Type returns "Text Document".

Methods

Copy(destination, overwrite) copies the file to the specified destination, overwriting any existing file by the same name if overwrite is set to True.

Delete(force) deletes the file. If force is set to True, the file is deleted even if set to read-only.

Move(destination) moves the file to destination.

OpenAsTextStream(iomode, format) returns a text stream object for the file. iomode indicates whether the file should be opened for reading (1), for writing (2), or for appending (8). If format is -1, it opens the file as Unicode. If it is 0, it opens it as ASCII. If format is -2, the file is opened according to the system default.

Top
Folder Object

The Folder object represents a single folder on the server.

Properties

Attributes is used to set and return some of the special attributes of the folder.

DateCreated returns the date and time that the folder was created. This is a read-only property.

DateLastAccessed returns the date and time the folder was last accessed. This is a read-only property.

DateLastModified returns the date and time the folder was last modified. This is a read-only property.

Drive returns the letter of the drive the folder is on. This is a read-only property.

Files returns a files collection consisting of all the file objects contained in the folder.

IsRootFolder has a value of True if the folder is the root folder of the current drive.

Name is used to set or return the name of the folder.

ParentFolder returns an instance of the folder object corresponding to the parent folder of the specified folder.

Path returns the path to the folder, including the name.

ShortName returns the version of the folder name used by programs that do not support long filenames.

ShortPath returns the path to the folder as it is seen by programs that do not support long filenames.

Size returns the size, in bytes, of all the files and subfolders contained in the folder.

Subfolders returns a folders collection consisting of all the folder objects contained within the folder.

Type returns information that is known about the type of the folder. For most folders this is simply "File Folder." Certain special folders, though, have their own type, such as "Recycle bin."

Methods

Copy(destination, overwrite) copies the folder to the specified destination, overwriting any existing folder by the same name if overwrite is set to True.

CreateTextFile(filename, overwrite, unicode) creates a text file and returns the TextStream object for it. If the file already exists, the Boolean value overwrite determines whether the file is overwritten. unicode is a Boolean value that if True causes the file to be created as Unicode, and if False, causes it to be created as ASCII. The default is ASCII.

Delete(force) deletes the folder. If force is set to True, the folder is deleted even if set to read-only.

Move(destination) moves the folder to destination.

Top
Drive Object

The Drive object may represent either an actual drive or a network drive.

Properties

AvailableSpace returns the amount of space available to the user on the drive or network share.

DriveLetter returns a string containing the drive letter. If the object is not associated with a drive letter, the result is a zero-length string ("").

DriveType returns a string indicating the type of the drive ("Removable" or CD-ROM" for example).

FileSystem returns the type of file system in use on the drive.

FreeSpace returns the amount of free space on the drive or network share.

IsReady is True if the specified drive is ready. This is useful in dealing with removable drives and CD-ROM drives.

Path is a string containing the drive's path.

RootFolder returns a folder object containing the root folder.

SerialNumber contains the serial number used to identify the drive.

ShareName returns a string containing the share name of the object. If the object is not a network drive, the result is a zero-length string ("").

TotalSize returns the total size of the drive or network share in bytes.

VolumeName returns the volume name of the drive.

Top
TextStream Object

The TextStream object is used for reading data in from a file and writing data out to a file.

Properties

AtEndOfLine is True if the pointer is at the end of a line in the file.

AtEndOfStream is True if the pointer is at the end of the file.

Column contains the column number of the current position in the file.

Line contains the line number of the current position in the file.

Methods

Close closes the file.

Read(num) reads in the next num characters from the file into a string.

ReadAll reads the entire file into a string.

ReadLine reads a single line of text into a string.

Skip(num) skips num characters when reading the file.

SkipLine skips a single line of text.

Write(string) writes string to the file.

WriteLine(string) writes string followed by a carriage return to the file. string is optional.

WriteBlankLines(num) writes num carriage returns to the file.

  Top
 
Logo
2004 © Technetex
Protected by Copyright. All Rights Reserved.