欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

vbscript 剔除文件夹失败 error: permission denied code: 800a0046

更新时间: 2014-01-05 01:52:18 责任编辑: Author_N1

 

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 delete
Set subFolders = deleteDir.Subfolders  'Get all the folders in the above directory
Set toBeDeletedFoldersPath = CreateObject( "System.Collections.ArrayList" ) 'Store the paths of the folders that need to be deleted

For Each folder in subFolders
    toBeDeletedFoldersPath.Add folder.path
Next

For Each folderPath in toBeDeletedFoldersPath
    fso.deleteFolder folderPath
Next

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

解决方法:

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

Set fso = CreateObject("Scripting.FileSystemObject")
Set deleteDir = fso.GetFolder("D:\FTP_Folder\vbScriptTest")   'Set the directory you want to delete
Set subFolders = deleteDir.Subfolders  'Get all the folders in the above directory
Set toBeDeletedFoldersPath = CreateObject( "System.Collections.ArrayList" ) 'Store the paths of the folders that need to be deleted

For Each folder in subFolders
    toBeDeletedFoldersPath.Add folder.path
Next

For Each folderPath in toBeDeletedFoldersPath
    fso.deleteFolder folderPath, True   'force the deletion of read-only files
Next

上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 01:52:18
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/2291/
本文WWW.DOC100.NET DOC100.NET版权所有。