<html>
<head>
<title>创建和删除文件夹</title>
</head>
<body>
<h2>创建和删除文件夹</h2>
<hr>
<script language="JavaScript">
var strFolder = "c:\\test";
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
// 检查文件夹是否存在
if (!objFSO.FolderExists(strFolder)){
// 创建文件夹
var strFolderName = objFSO.CreateFolder(strFolder);
document.write("创建文件夹: " + strFolderName + "<br>");
}
// 检查文件夹是否存在
if (objFSO.FolderExists(strFolder)){
document.write("文件夹: " + strFolder + "存在<br>");
// 删除文件夹
objFSO.DeleteFolder(strFolder, false);
document.write("删除文件夹: " + strFolder + "成功<br>");
}
else
document.write("文件夹不存在<br>");
</script>
</body>
</html>
<head>
<title>创建和删除文件夹</title>
</head>
<body>
<h2>创建和删除文件夹</h2>
<hr>
<script language="JavaScript">
var strFolder = "c:\\test";
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
// 检查文件夹是否存在
if (!objFSO.FolderExists(strFolder)){
// 创建文件夹
var strFolderName = objFSO.CreateFolder(strFolder);
document.write("创建文件夹: " + strFolderName + "<br>");
}
// 检查文件夹是否存在
if (objFSO.FolderExists(strFolder)){
document.write("文件夹: " + strFolder + "存在<br>");
// 删除文件夹
objFSO.DeleteFolder(strFolder, false);
document.write("删除文件夹: " + strFolder + "成功<br>");
}
else
document.write("文件夹不存在<br>");
</script>
</body>
</html>