|
-
September 23rd, 2001, 09:32 PM
#1
search a file in vb
how can i search a file in windows system using vb program.? i just need a code for that.
thank u and regards.
bhaskar reddy.
-
September 24th, 2001, 12:33 AM
#2
Re: search a file in vb
If Dir$("c:\windows\system\seekfile.ext") <> "" Then
'file is found
-
September 24th, 2001, 09:31 AM
#3
Re: search a file in vb
Here is a sample program that uses the "SearchforFile" API to scan a directory tree for a specified file. IN the example it is looking for VB6.exe
option Explicit
'1).Start a new project.
'2).Add a Animation Control to the form. (The animation control is part of "Microsoft Windows Common Controls-2 6.0 in the Project Components list.
'3).Add a Command Button (Command1).
'4).Paste the following code into the General Declarations section of the Form.
'5).Edit the code, looking for the "AVIFile = " statement and make sure it has the correct path to the "Search.avi" file.
'6).Change the statement which reads "Ret = SearchTreeForFile("C:\", "vb6.exe", tempStr)" to the executable of your choice.
'7).Run the program
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()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
' Note: Search AVI stuff added by me jgd
Dim tempStr as string, Ret as Long
Dim AVIFile as string
'create a buffer string
me.Show
AVIFile = "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Videos\search.avi"
anmAVI.Open AVIFile
anmAVI.Play
'returns 1 when successfull, 0 when failed
tempStr = string(MAX_PATH, 0)
Ret = SearchTreeForFile("C:\", "vb6.exe", tempStr)
anmAVI.Stop
anmAVI.Close
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
John G
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
|