|
-
Jun 19th, 2000, 04:05 AM
#1
Thread Starter
Addicted Member
Hello, I am trying to write a program that loops every every file/sub-dir in a specified path and repair/compact every MDB it finds. I have figured out how to repair/compact the db, but how do I loop through every file in a specified path? Like I would tell the program to start at S:\DATA and it would find all of the MDB's in S:\DATA and its sub-dirs and repair/compact the db. Any help would be appreciated, thanks!
Thai
-
Jun 19th, 2000, 04:15 AM
#2
_______
might help..
'loop through a dir
Dim sDir As String
sDir = Dir("C:\*.*", vbNormal + vbHidden + vbArchive + vbReadOnly + vbSystem)
While sDir <> ""
sDir = Dir
'do whatever
Wend
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 19th, 2000, 04:30 AM
#3
Thread Starter
Addicted Member
That doesn't check the subdirectories and it also doesn't return the full path of the filename. I need something that will loop through every sub dir also and return the full path so I can plug it into my repair/compact function.
Thanks though,
Thai
-
Jun 19th, 2000, 04:36 AM
#4
Hyperactive Member
A recursive function is what you need.
Function rec_dir_func
root dir
repair files if any found
Loop Through list of sub dirs in root dir
rec_dir_func(new root path)
Next Loop
End Function
-
Jun 19th, 2000, 07:17 AM
#5
transcendental analytic
For subdirectories and files:
This is my classmodule from which you can fire the events, but you can simply put your own code instead of the raisevent statements.
Code:
Option Explicit
Event Filecatch(File As String, Path As String, level As Integer)
Event Direcatch(dire As String, Path As String, level As Integer)
Public curlevel%
Public filemax&
Public diremax&
Public tid&
Sub explore(startdir$, Optional pauses = 100)
Dim tids&
tids = Timer
filemax = 0: diremax = 0: curlevel = 0
If Right(startdir, 1) <> "\" Then startdir = startdir & "\"
SubFiles startdir, pauses
tid = Timer - tids
End Sub
Function SubFiles(Path$, Optional pauses = 100): Dim i&, dmax&, dirname$, dire$(), waiter&
dirname = Dir(Path, 63)
Do While dirname <> ""
If dirname <> "." And dirname <> ".." Then
If Int(GetAttr(Path + dirname) / 16) Mod 2 = 1 Then
If (dmax Mod 10) = 0 Then
ReDim Preserve dire(dmax + 10) ' Resize the array.
End If
diremax = diremax + 1: dmax = dmax + 1
dire(dmax) = dirname
RaiseEvent Direcatch(dirname, Path, curlevel)
Else
filemax = filemax + 1
RaiseEvent Filecatch(dirname, Path, curlevel)
End If
End If
dirname = Dir ' Get another directory name.
waiter = waiter + 1: If waiter Mod (pauses) = 1 Then DoEvents
Loop
For i = 1 To dmax
curlevel = curlevel + 1
SubFiles Path & dire(i) & "\"
Next i
curlevel = curlevel - 1
End Function
[Edited by kedaman on 06-19-2000 at 08:29 PM]
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|