OBJECT:  FileSystemObject

Implemented in version 2.0
 
The FileSystemObject is used to gain access to a computer's file system. It can create new files and access existing ones.
 
The following code uses the CreateTextFile method of the FileSystemObject object to create a text file (c:\somefile.txt) and then writes some text to it.
 
Code:
<%
dim filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("c:\somefile.txt", True)
path = filesys.GetAbsolutePathName("c:\somefile.txt")
getname = filesys.GetFileName(path)
filetxt.WriteLine("Your text goes here.")
filetxt.Close
If filesys.FileExists(path) Then
   Response.Write ("Your file, '" & getname & "', has been created.")
End If
%>
Output:
"Your file, 'somefile.txt', has been created."
 
PROPERTIES

Drives Property
Returns a Drives collection consisting of all the Drive objects on a computer.

Syntax: [drvcollection = ] object.Drives

METHODS

BuildPath Method
This method is used to append a name onto an existing path.

[newfullpath = ]object.BuildPath(path, name)

CopyFile Method
This method allows us to copy one or more files from one location (the source) to another (destination).

Syntax: object.CopyFile source, destination [, overwrite]

CopyFolder Method
Copies one or more folders and all contents, including files and subfolders, from one location to another.

Syntax: object.CopyFolder source, destination, [, overwrite]

CreateFolder Method
This method allows us to create a folder.

Syntax: object.CreateFolderfoldername

CreateTextFile Method
Creates a text file and returns a TextStreamObject that can then be used to write to and read from the file.

Syntax: object.CreateTextFile filename [, overwrite[, unicode]]

DeleteFile Method
This method deletes a specified file or files (using wilcards).

Syntax: object.DeleteFile file [, force]

DeleteFolder Method
This method deletes a specified folder, including all files and subfolders.

Syntax: object.DeleteFolder folder [, force]

DriveExists Method
This method lets us check if a specified drive exists. It returns True if the drive does exist and False if it doesn't.

Syntax: object.DriveExists(drive)

FileExists Method
Lets us check whether a specified file exists. Returns True if the file does exist and False otherwise.

Syntax: object.FileExists(file)

FolderExists Method
Allows us to check if a specified folder exists. Returns True if the folder does exist and False if it doesn't.

Syntax: object.FolderExists(folder)

GetAbsolutePathName Method
This method gets the complete path from the root of the drive for the specified path string.

Syntax: object.GetAbsolutePathName(path)

GetBaseName Method
This method gets the base name of the file or folder in a specified path.

Syntax: object.GetBaseName(path)

GetDrive Method
This method returns a Drive object corresponding to the drive in a supplied path.

Syntax: object.GetDrive(drive)

GetDriveName Method
This method gets a string containing the name of the drive in a supplied path.

Syntax: object.GetDriveName(path)

GetExtensionName Method
Used to return a string containing the extension name of the last component in a supplied path.

Syntax: object.GetExtensionName(path)

GetFile Method
Returns the File object for the specified file name.

Syntax: object.GetFile(filename)

GetFileName Method
This method is used to return the name of the last file or folder of the supplied path.

Syntax: object.GetFileName(path)

GetFolder Method
This method returns a Folder object fo the folder specified in the folder parameter.

Syntax: object.GetFolder(folder)

GetParentFolderName Method
Returns a string containing the name of the parent folder of the last file or folder in a specified path.

Syntax: object.GetParentFolderName(path)

GetSpecialFolder Method
Returns the path to one of the special folders - \Windows, \System or \TMP.

Syntax: object.GetSpecialFolder(folder)

GetTempName Method
This method is used to generate a random filename for a temporary file..

Syntax: object.GetTempName

MoveFile Method
Moves one or more files from one location to another.

Syntax: object.MoveFile source, destination

MoveFolder Method
Moves one or more folders from one location to another.

Syntax: object.MoveFolder source, destination

OpenTextFile Method
Opens the file specified in the filename parameter and returns an instance of the TextStreamObject for that file.

Syntax: object.OpenTextFile(filename [, iomode[, create[, format]]])


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information