Click to See Complete Forum and Search --> : How can I search Files in Drives and get it's Path?
MilesNepo
July 2nd, 2001, 04:50 AM
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.
Cakkie
July 2nd, 2001, 06:08 AM
I think this is just what you need ;)
http://www.vb-world.net/files/tip529.html
Tom Cannaerts
slisse@planetinternet.be
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
Iouri
July 2nd, 2001, 06:59 AM
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
iouri@hotsheet.com
MilesNepo
July 4th, 2001, 03:43 AM
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
MilesNepo
July 4th, 2001, 05:25 AM
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!
Cakkie
July 4th, 2001, 05:49 AM
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
slisse@planetinternet.be
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
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.