Latest web development tutorials

ASP FileSystem Object

FileSystemObject object is used to access the file system on the server.


Examples

Try - Example

The specified file exist?
This example demonstrates how to check whether a file exists.

Specified folder exist?
This example demonstrates how to check if a folder exists.

Specified drive exist?
This example demonstrates how to check a drive exists.

Get the name of a specified drive
This example demonstrates how to obtain a specified drive name.

Name obtain a specified path to the parent folder
This example demonstrates how to obtain the name of the parent file a specified folder path.

Get filename
This example demonstrates how to obtain the specified path of the last component of the file name.

Obtain the file name extension
This example demonstrates how to obtain the file name extension specified path of the last ingredient.

Made base name of the file or folder
This example shows how to get the name of the base path specified files or folders.


FileSystemObject Object

FileSystemObject object is used to access the file system on the server.

This object can be a file, folder and directory paths to operate. Information is also available via the file system object.

The following code creates a text file (c: \ test.txt), and then write some text to the 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
%>

FileSystemObject object properties and methods are described below:

Attributes

属性 描述
Drives 返回本地计算机上所有驱动器对象的集合。

method

方法 描述
BuildPath 将一个名称追加到已有的路径后。
CopyFile 从一个位置向另一个位置拷贝一个或多个文件。
CopyFolder 从一个位置向另一个位置拷贝一个或多个文件夹。
CreateFolder 创建新文件夹。
CreateTextFile 创建文本文件,并返回一个可以读取或者写入文件的 TextStream 对象。
DeleteFile 删除一个或者多个指定的文件。
DeleteFolder 删除一个或者多个指定的文件夹。
DriveExists 检查指定的驱动器是否存在。
FileExists 检查指定的文件是否存在。
FolderExists 检查指定的文件夹是否存在。
GetAbsolutePathName 针对指定的路径返回从驱动器根部起始的完整路径。
GetBaseName 返回指定文件或者文件夹的基名称。
GetDrive 返回指定路径中所对应的驱动器的 Drive 对象。
GetDriveName 返回指定的路径的驱动器名称。
GetExtensionName 返回在指定的路径中最后一个成分的文件扩展名。
GetFile 返回一个针对指定路径的 File 对象。
GetFileName 返回在指定的路径中最后一个成分的文件名或者文件夹名。
GetFolder 返回一个针对指定路径的 Folder 对象。
GetParentFolderName 返回在指定的路径中最后一个成分的父文件夹名称。
GetSpecialFolder 返回某些 Windows 的特殊文件夹的路径。
GetTempName 返回一个随机生成的文件或文件夹。
MoveFile 从一个位置向另一个位置移动一个或多个文件。
MoveFolder 从一个位置向另一个位置移动一个或多个文件夹。
OpenTextFile 打开文件,并返回一个用于访问此文件的 TextStream 对象。