Hi all,
Is there some way to find where a particular file is situated. It may in any Drive/Folder. No we are not to use any drive/file listbox etc.. simply a command button which displays the location onto a lable or msgbox. :eek:
Printable View
Hi all,
Is there some way to find where a particular file is situated. It may in any Drive/Folder. No we are not to use any drive/file listbox etc.. simply a command button which displays the location onto a lable or msgbox. :eek:
This will also work without the overhead of the FSOCode:Private Declare Function SearchTreeForFile Lib "imagehlp" _
(ByVal RootPath As String, ByVal InputPathName As String, _
ByVal OutputPathBuffer As String) As Long
Private Const MAX_PATH = 260
Private Sub Command1_Click()
Dim tempStr As String, Ret As Long
'create a buffer string
tempStr = String(MAX_PATH, 0)
'returns 1 when successfull, 0 when failed
Ret = SearchTreeForFile("c:\", "myfile.exe", tempStr)
If Ret <> 0 Then
MsgBox "Located file at " + Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
Else
MsgBox "File not found!"
End If
End Sub
Nice one Hack, but what if more files with the same name in different folders? ;)
Then you wouldn't use that API.Quote:
Originally Posted by Radjesh Klauke
However, the original question wasA particular file indicates the OP is interested in finding just one file.Quote:
Originally Posted by VBFnewcomer
I don't get it. There is no such concept as "a particular file" that I know about. There is just "all files that have name xxxxxxx".Quote:
Originally Posted by VBFnewcomer
So do you want a listbox with all the directories that files with a given name appear in? A bit like the Windows F3 search?
Mac
Thank you both Radjesh & Hack, as well as Randem & Static (in the link thread).Hack was right. However the links provided me with enough material which I could use in another context. By the way which of the approaches is faster and take less mem Hack's or Randem or Static.Quote:
A particular file indicates the OP is interested in finding just one file.