Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 17th, 2006, 05:28 PM
kcconnor's Avatar
kcconnor kcconnor is offline
Evil Republican...
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Probably running over your cat right now...
Posts: 250 kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 21 h 35 m 23 sec
Reputation Power: 37
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

Reply With Quote
  #2  
Old March 17th, 2006, 09:52 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
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

Reply With Quote
  #3  
Old March 22nd, 2006, 11:38 AM
kcconnor's Avatar
kcconnor kcconnor is offline
Evil Republican...
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Probably running over your cat right now...
Posts: 250 kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 21 h 35 m 23 sec
Reputation Power: 37
Quote:
Originally Posted by Doug G
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?


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.

Reply With Quote
  #4  
Old March 22nd, 2006, 10:57 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
I'm glad you got it worked out.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > ObjFSO.DeleteFile with Wildcards?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT