当前位置: 代码迷 >> vbScript >> VBScript 剔除文件夹失败 Error: Permission Denied Code: 800A0046
  详细解决方案

VBScript 剔除文件夹失败 Error: Permission Denied Code: 800A0046

热度:4594   发布时间:2013-02-26 00:00:00.0
VBScript 删除文件夹失败 Error: Permission Denied Code: 800A0046

症状:

1. 运行下面的VBScript脚本,删除某个目录下的所有文件夹:

Set fso = CreateObject("Scripting.FileSystemObject")Set deleteDir = fso.GetFolder("D:\FTP_Folder\vbScriptTest")   'Set the directory you want to deleteSet subFolders = deleteDir.Subfolders  'Get all the folders in the above directorySet toBeDeletedFoldersPath = CreateObject( "System.Collections.ArrayList" ) 'Store the paths of the folders that need to be deletedFor Each folder in subFolders    toBeDeletedFoldersPath.Add folder.pathNextFor Each folderPath in toBeDeletedFoldersPath    fso.deleteFolder folderPathNext

 对于某些文件目录能够删除成功,但是对于某些目录却得到如下的运行时错误:

解决方法:

1. 像下面这样在第11行代码末尾加一个参数True,表示强制删除只读文件夹:

Set fso = CreateObject("Scripting.FileSystemObject")Set deleteDir = fso.GetFolder("D:\FTP_Folder\vbScriptTest")   'Set the directory you want to deleteSet subFolders = deleteDir.Subfolders  'Get all the folders in the above directorySet toBeDeletedFoldersPath = CreateObject( "System.Collections.ArrayList" ) 'Store the paths of the folders that need to be deletedFor Each folder in subFolders    toBeDeletedFoldersPath.Add folder.pathNextFor Each folderPath in toBeDeletedFoldersPath    fso.deleteFolder folderPath, True   'force the deletion of read-only filesNext

  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Thu Mar 23 20:31:59 CST 2017
  • 最近登录:Thu Mar 23 20:31:59 CST 2017
  • 最近登录:Thu Mar 23 20:31:59 CST 2017
  • 最近登录:Thu Mar 23 20:31:59 CST 2017
  • 最近登录:Thu Mar 23 20:31:59 CST 2017