473,652 Members | 3,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drilling down for zip files, how can I reach every subdirectory?

Lokean
71 New Member
Hi folks,

Here's what I have so far...
Expand|Select|Wrap|Line Numbers
  1. Dim fso, fol, subfol, fo, fls, fl, subfol2, subfol3
  2.  
  3. sSearchString = "C:\"
  4.  
  5.     Set fso = CreateObject("Scripting.FileSystemObject")
  6.     Set fol = fso.getfolder("C:\")
  7.     Set subfol = fol.subfolders
  8.  
  9.  
  10.     For Each fo In subfol
  11.         On Error GoTo Resumeit
  12.        Set fls = fo.Files
  13.  
  14.        'Else
  15.        For Each fl In fls
  16.           If UCase(Right((fl.Name), 3)) = "ZIP" Then
  17.             ' MsgBox fl.Name
  18.           End If
  19.         Next fl
  20.  
  21. Resumeit2:
  22.     Next fo
This gets me down to one level below C:\, but I need to get to every subdirectory and pull out all the zip files that are floating around.

application.fil esearch does not recognize .zip files as files, so that trick is out.

This is as close as I've come.

Can anyone help me drill down from here? Is there a better method?

Thanks in advance.
Apr 3 '07 #1
1 1092
Killer42
8,435 Recognized Expert Expert
I have tackled this exact problem of traversing folders in the past. The technique I came up with (based largely on someone else's example, I think) is a reentrant routine - that is, one which calls itself. I'll have a dig around for some source code later. but the general method was something like this (just pseudo-code)...

Expand|Select|Wrap|Line Numbers
  1. Sub ProcessFolder (fld as Folder)
  2.  
  3.   For each SubFolder in fld
  4.     ProcessFolder SubFolder
  5.   Next
  6.  
  7.   For each File in fld
  8.     ProcessFile File
  9.   Next
  10.  
  11. End Sub
  12.  
  13. Sub ProcessFile (fil as File)
  14.  
  15.   ' Do whatever you want with fil here.
  16.  
  17. End Sub
Note, when writing a routine which will call itself like this, where each iteration must be separate, it's important to avoid using Static variables (unless you really know you need them)
Apr 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1504
by: Mart Rogers | last post by:
I have an asp.net project which includes some javascript files which live in a subdirectory to the project root directory. The include statements obviously expect the files to be in that subdirectory. I wish to debug the javascript, but when I try to add the files to the project, they are copied into the project root directory. I tried to 'create' a folder in Solution Explorer and hand copied the files in there, and then tried to add...
4
2329
by: Larry R Harrison Jr | last post by:
I have them working now, courtesy of the link given in the prior thread--the HVMenu over at Dynamic Drive myself. http://www.dynamicdrive.com I have them working as side-bar menus, not horizontal ones on TOP of the page. I figured it out and have it working fine, except for one thing--apparently I need to insert the code for the menu for every last HTML file I have
10
9910
by: TokiDoki | last post by:
Hello there, I have been programming python for a little while, now. But as I am beginning to do more complex stuff, I am running into small organization problems. It is possible that what I want to obtain is not possible, but I would like the advice of more experienced python programmers. I am writing a relatively complex program in python that has now around 40 files.
8
2385
by: RML | last post by:
hey guys, i am looking at this piece of code that lists numbers of files in a directory. i want to convert it so it lists the files in th directory that end with .doc. i cant seem to get it to output correctly, i have included the original code, my modified code, and the output from my modifed code.. why does it list the files as "System.IO.FileInfo"??? thanks
4
10566
by: Bennett Haselton | last post by:
If I add this to my web.config file: <authentication mode="Forms"> <forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All" timeout="60" /> </authentication> I can configure the application so that users who try to access a page in the application, get redirected to login.aspx where they have to sign in. (And the "signing in" is handled in the codebehind page of
4
1272
by: Kivak | last post by:
Hey everyone, I know we have to be able to do this, or Microsoft was stupid. How do we get down to the very variables in the DataGrid and FormView? Lets say I have a table to hold a product ID and the product name... ----------------------- | ID: | Name: | | 1 | MyProduct1 | | 2 | MyProduct2 |
4
1252
by: tim | last post by:
Hi all! How to create array of string, which contains names of all files with full path in special folder (e.g. c:\windows). In this folder it may be subfolders of various levels.
4
1364
by: Jack Russell | last post by:
I need to drill down from a directory through all the sub directories and build up a list of files. I have VB6 code to do this but it uses APIs etc and am hoping that there is a better way of doing in .net 2003 I would appreciate any help or examples that anyone can give me Thanks Jack Russell
1
3138
by: Claire | last post by:
Ive written a small string resource building utility that I send out to our translators. I have a setup project for each language we support, which picks out a group of 12 english resx files plus their paired "foreign" resx for that language only and installs those resource files in a subdirectory somewhere. I'm trying to create a setup project in visual studio 2008. Ive got my Application Folder set up with my executable. Im now...
0
8367
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.