|
-
May 30th, 2000, 08:16 PM
#1
Thread Starter
New Member
I think I have searched the entire web for a code that searches my computer for a file i for example put in a textbox.
Could anyone please give me such a code?
-
May 30th, 2000, 08:52 PM
#2
transcendental analytic
Filename or files with the text contained in files?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 30th, 2000, 09:07 PM
#3
_______
code
'does file exist using fso
Dim sFile$
sFile = "Name And Path Of Your File"
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists(sFile$) = True Then
MsgBox "File Exists...Your code here!"
Else
MsgBox "Does Not Exist...Your code here!"
End If
Set fs = Nothing
Enjoy
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
May 30th, 2000, 09:11 PM
#4
Fanatic Member
Or if you want to search the hard drive for a file.
Code:
Option Explicit
Option Compare Text
Dim fso
Dim blFound As Boolean
Private Sub Command2_Click()
Dim myFolder
'create a file scripting object
Set fso = CreateObject("Scripting.FileSystemObject")
Me.Caption = "Working!"
'the folder to start looking in
myFolder = "c:\"
searchFileNames fso.getfolder(myFolder).Files, Text1.Text
searchFolderNames fso.getfolder(myFolder).subfolders, Text1.Text
blFound = False
Me.Caption = "DONE!"
End Sub
Private Sub searchFolderNames(myFolderList, strFile As String)
Dim myFolder
For Each myFolder In myFolderList
If blFound = True Then Exit Sub
'search the files for this folder
searchFileNames fso.getfolder(myFolder).Files, strFile
If myFolder.Name = strFile Then
MsgBox "Folder Found at : " & myFolder.Path
blFound = True
Exit Sub
End If
'recursivley search the folders
searchFolderNames fso.getfolder(myFolder).subfolders, strFile
Next
End Sub
Private Sub searchFileNames(myFolder, strFile As String)
Dim MyFile
For Each MyFile In myFolder
If MyFile.Name = strFile Then
MsgBox "File Found at : " & MyFile.Path
blFound = True
Exit Sub
End If
Next
End Sub
Hope it helps.
Iain, thats with an i by the way!
-
May 31st, 2000, 04:03 AM
#5
Or you can use the FindFirstFile API.
Code:
Declare Function FindFirstFile Lib "kernel32.dll" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
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
|