|
-
July 2nd, 2001, 04:50 AM
#1
How can I search Files in Drives and get it's Path?
I'd like to get the Path of a file in a Drive.
For Ex.
FileName = "Northwind.mdb"
I'd like to know the exact path of where Northwind.mdb is in my "C:" Hard Drive
or my "D:" Mapped Network Drive.
I need to get the exact path so that I can point to that Database and Compact
that Database.
I'm trying to make an Access .mdb that will compact another .mdb Database.
I'm able to do this but I have a problem with setting the Path of the Database
to Compact.
In Access CurDir() does not work because it always has "My Documents" as its value.
-
July 2nd, 2001, 06:08 AM
#2
Re: How can I search Files in Drives and get it's Path?
I think this is just what you need 
http://www.vb-world.net/files/tip529.html
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
July 2nd, 2001, 06:59 AM
#3
Re: How can I search Files in Drives and get it's Path?
Just to add to Cakkie answer.
If you need only path (withoy the file name) then use the following code
Private Function GetModelPath(ByVal flname As String)
'=============================================================================
Dim sPath As String
Dim i As Integer
Dim sTemp As String
sTemp = flname
For i = 1 To Len(flname)
If Right(sTemp, 1) = "\" Then
GetModelPath = sTemp
Exit For
Else
sTemp = Left(flname, Len(flname) - i)
End If
Next i
End Function
Iouri Boutchkine
[email protected]
-
July 4th, 2001, 03:43 AM
#4
Re: How can I search Files in Drives and get it's Path?
Thanks for the Reply, I really appreciate it.
I'll try the code and see if it works.
I'd like to ask if you know a substitute for CurDir() in MS Access,
I'm having problems with this. In VB it gives the correct path if
you use CurDir() like if you're current directory is "c:\Program Files/Programs"
then it will display that Path, but in Access it always show "C:\My Documents".
Thanks
-
July 4th, 2001, 05:25 AM
#5
Re: How can I search Files in Drives and get it's Path?
Thanks, I've checked the code and used it and it works. But I was wondering if it's possible to get all of the occurences of the file in the Drive.
Ex. "vb.exe" is located in "C:\Program Files\vb.exe", "C:\My Documents\vb.exe",
"D:\Projects\vb.exe", "E:\Installers\vb.exe", etc.
Thanks!
-
July 4th, 2001, 05:49 AM
#6
Re: How can I search Files in Drives and get it's Path?
http://www.vb-world.net/files/findfiles/
This is another way to do that, this finds all the files, just change the *.* into whatever you need.
Note: the Dir version doesn't work correctly on NT4
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
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
|