can u tell me how to find a file with specified name and copy it to a folder?
Printable View
can u tell me how to find a file with specified name and copy it to a folder?
VB Code:
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() Screen.MousePointer = vbHourglass 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:\", "winword.exe", tempStr) If Ret <> 0 Then MsgBox "Located file at " + Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1) FileCopy tempStr, "c:\program files\winword.exe" Else MsgBox "File not found!" End If Screen.MousePointer = vbDefault End Sub
But keep in mind, since imagehlp is not part of the standard Win32 API, you'd have to include it with your project when you package it.