ASP FileSystemObject Object
- Previous Page ASP Error
- Next Page ASP TextStream
The FileSystemObject is used to access the file system on the server.
Example
- Does the specified file exist?
- This example demonstrates how to first create a FileSystemObject and then use the FileExists method to detect if a specified file exists.
- Does the specified folder exist?
- This example demonstrates how to use the FolderExists method to detect if a specified folder exists.
- Does the specified drive exist?
- This example demonstrates how to use the DriveExists method to detect if a specified drive exists.
- Get the name of a specified drive
- This example demonstrates how to use the GetDriveName method to obtain the name of a specified drive.
- Get the name of the parent folder of a specified path
- This example demonstrates how to use the GetParentFolderName method to obtain the name of the parent folder of a specified path.
- Get the folder extension
- This example demonstrates how to use the GetExtensionName method to obtain the file extension of the last component in a specified path.
- Get the file name
- This example demonstrates how to use the GetFileName method to obtain the file name of the last component in a specified path.
- Get the base name of a file or folder
- This example demonstrates how to use the GetBaseName method to return the base name of a file or folder in a specified path.
FileSystemObject object
The FileSystemObject is used to access the file system on the server. This object can perform operations on files, folders, and directory paths. It can also be used to obtain information about the file system.
The following code creates a text file (c:\test.txt) and then writes some text to this file:
<% dim fs,fname set fs=Server.CreateObject("Scripting.FileSystemObject") set fname=fs.CreateTextFile("c:\test.txt",true) fname.WriteLine("Hello World!") fname.Close set fname=nothing set fs=nothing %>
The properties and methods of the FileSystemObject object are described as follows:
Properties
Properties | Description |
---|---|
Drives | Returns a collection of all drive objects on the local computer. |
Method
Method | Description |
---|---|
BuildPath | Appends a name to the end of an existing path |
CopyFile | Copies one or more files from one location to another. |
CopyFolder | Copies one or more folders from one location to another. |
CreateFolder | Creates a new folder. |
CreateTextFile | Creates a text file and returns a TextStream object. |
DeleteFile | Deletes one or more specified files. |
DeleteFolder | Deletes one or more specified folders. |
DriveExists | Checks if a specified drive exists. |
FileExists | Checks if a specified file exists. |
FolderExists | Checks if a folder exists. |
GetAbsolutePathName | Returns the complete path starting from the root of the drive for the specified path. |
GetBaseName | Returns the base name of the specified file or folder. |
GetDrive | Returns the Drive object corresponding to the drive at the specified path. |
GetDriveName | Returns the drive name of the specified path. |
GetExtensionName | Returns the file extension of the last component in the specified path. |
GetFile | Returns a File object for the specified path. |
GetFileName | Returns the file name of the last component in the specified path. |
GetFolder | Returns a Folder object for the specified path. |
GetParentFolderName | Returns the parent folder name of the last component in the specified path. |
GetSpecialFolder | Returns the path of certain special folders in Windows. |
GetTempName | Returns a randomly generated file or folder. |
MoveFile | Move one or more files from one location to another. |
MoveFolder | Move one or more folders from one location to another. |
OpenTextFile | Open a file and return a TextStream object for accessing this file. |
- Previous Page ASP Error
- Next Page ASP TextStream