ASP编程教程技巧综合大全(45)
fso.DeleteFolder ("C:\Bogus")
Response.Write "Deleted folder C:\Bogus" & "
"
End Sub
下面的示例显示如何在 JScript 中使用 Folder 和 FileSystemObject 对象:
function ShowFolderInfo()
{
var fso, fldr, s = "";
// 获得 FileSystemObject 的实例。
fso = new ActiveXObject("Scripting.FileSystemObject");
// 获得 Drive 对象。
fldr = fso.GetFolder("c:");
// 打印父文件夹名。
Response.Write("Parent folder name is: " + fldr + "
");
// 打印驱动器名字。
Response.Write("Contained on drive " + fldr.Drive + "
");
// 打印根文件名。
if (fldr.IsRootFolder)
Response.Write("This is the root folder.");
else
Response.Write("This folder isn''t a root folder.");
Response.Write("
");
// 用 FileSystemObject 对象创建新的文件夹。
fso.CreateFolder ("C:\\Bogus");
Response.Write("Created folder C:\\Bogus" + "
");
// 打印文件夹的基本名。
Response.Write("Basename = " + fso.GetBaseName("c:\\bogus") + "
");
// 删除新创建的文件夹。
fso.DeleteFolder ("C:\\Bogus");
Response.Write("Deleted folder C:\\Bogus" + "
");
}