|
-
Jan 13th, 2000, 05:31 PM
#1
Thread Starter
Lively Member
Question: Creating app that will give me just the file name of any file in a specified directory with the extension .rar.
FSO doesn't seem to understand wildcards in VB. Is there a way to make it give me back just the file name? The File name will never be the same.
-
Jan 13th, 2000, 09:07 PM
#2
Try this:
Public Function GetRARFile(sPath As String) As String
Dim sFile$
sPath = sPath & IIf(Right$(sPath, 1)<>"\", "\", "")
sFile = Dir(sPath & "*.rar")
If Len(sFile) Then
GetRARFile = Mid$(sFile, InStrRev(sFile, "\") + 1)
End If
End Function
Good luck!
------------------
Joacim Andersson
[email protected]
[email protected]
www.YellowBlazer.com
-
Jan 14th, 2000, 02:58 AM
#3
1. start new project
2. add a command button named command1 to the form
3. reference the scripting run time
4. cut and paste the following in the code module of the form:
Option Explicit
Private Sub Command1_Click()
FindFilesWithExtension "tmp", "c:\temp"
End Sub
Public Sub FindFilesWithExtension(ByVal strExtensionToFind, ByVal strDirectoryToSearch)
Dim fso As Scripting.FileSystemObject
Dim fsoFile As Scripting.File
Set fso = New Scripting.FileSystemObject
For Each fsoFile In fso.GetFolder(strDirectoryToSearch).Files
If fso.GetExtensionName(fsoFile) = strExtensionToFind Then
Debug.Print fso.GetExtensionName(fsoFile)
End If
Next
Set fso = Nothing
End Sub
-
Jan 17th, 2000, 04:47 AM
#4
Thread Starter
Lively Member
Thanks for your help guys! That was exactly what I needed!
<c>
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
|