|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
ObjFSO.DeleteFile with Wildcards?
Trying to build a script to go thru some nested directories and delete any file with a specific extension.
Example paths are: R:\AppName\Folder1\FaxQueue\somefile.fmi R:\AppName\Folder2\FaxQueue\someotherfile.fmi For about 25 folders. Example code: Code:
Option Explicit
Dim RootFolder,Folderpath
Dim i
Dim aFolderList()
RootFolder = "R:\AppName\"
Folderpath = "Records\FaxQueue\"
FillFolderList
EmptyFolders
on error resume next
Sub FillFolderList
ReDim aFolderList(3)
aFolderList(0) = "Client1"
aFolderList(1) = "Client2"
aFolderList(2) = "Client3"
end sub
sub EmptyFolders()
On Error Resume Next
Dim objFSO
set objFSO = CreateObject("Scripting.FileSystemObject")
For i = 0 to UBOUND(aFolderList) - 1
objFSO.DeleteFile(RootFolder & aFolderList(i) & Folderpath & "*.FMI")
next
end sub
When I run this, I have a known *.FMI file in a targeted directory that is not being deleted. Any ideas?
__________________
IF ADVICE = 'GOOD' INSERT INTO scales (REPUTATION_POINTS, REASON) VALUES (+1, 'BECAUSE ITS GOOD TO DO THAT') END |
|
#2
|
|||
|
|||
|
Wildcards work with the DeleteFile method, perhaps the file that's not getting deleted is a read-only file or has permission settings that prevent deletion?
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
||||
|
||||
|
Quote:
Account is a domain admin account and no read-only flags on file. I found the problem. I'm constructing a path that I want to read as "R:\AppName\Client1\Records\FaxQueue" but when I ran under the current code I ended up getting "R:\AppName\Client1Records\FaxQueue". I adjusted the following code: Code:
Folderpath = "Records\FaxQueue" 'to read like Folderpath = "\Records\FaxQueue" Works perfectly now. Thanks for your help anyways, Doug. |
|
#4
|
|||
|
|||
|
I'm glad you got it worked out.
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > ObjFSO.DeleteFile with Wildcards? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|