MyException - 我的異常網
當前位置:我的異常網» vbScript » VBScript 剔除文件夾失敗 Error: Permission Denied

cf手游怎么卡刀bug:VBScript 剔除文件夾失敗 Error: Permission Denied Code: 800A0046

cf手游刷枪永久枪软件 www.yqwdk.icu  網友分享于:2013-01-19  瀏覽:40次
VBScript 刪除文件夾失敗 Error: Permission Denied Code: 800A0046

cf手游刷枪永久枪软件 www.yqwdk.icu 癥狀:

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

文章評論

軟件開發程序錯誤異常cf手游刷枪永久枪软件Copyright © 2009-2015 MyException 版權所有