|
-
Oct 28th, 2000, 02:01 AM
#1
Thread Starter
PowerPoster
I am opening a file, but I would only like to see the filename itself, not the whole path to the image. I've been trying to figure this out for some time, but I finally decided to give up and come to you guys.
Thanks in advance,
MidgetsBro
-
Oct 28th, 2000, 04:33 AM
#2
Hyperactive Member
Maybe this helps:
Code:
Private Sub Form_Load()
Dim FullFile, Filename, Temp As String
Dim I As Integer
FullFile = "c:\MyMap\MySubMap\MyFile.txt"
For I = 0 To Len(FullFile)
Temp = Mid(FullFile, Len(FullFile) - I, 1) 'select 1 character
If Temp = "\" Then 'if the caracter is a slash
Filename = Mid(FullFile, Len(FullFile) - I + 1, I) 'delete the piece of path witch comes before the slash and the slash itself
Exit For
End If
Next I
MsgBox FullFile & " was turned into " & Filename :)
End Sub
WP
-
Oct 28th, 2000, 08:03 AM
#3
Fanatic Member
Run the code below to see a few of the features of using the FileSystemObject on a file path.
Code:
Private Sub Command1_Click()
Dim oFSO As Object
Dim filePath As String
Set oFSO = CreateObject("Scripting.FileSystemObject")
filePath = "c:\folder1\folder2\textfile.txt"
MsgBox "Filename (no extension) = " & oFSO.getbasename(filePath) & vbCrLf & _
"Filename with extension = " & oFSO.getfilename(filePath) & vbCrLf & _
"Extension = " & oFSO.getextensionname(filePath) & vbCrLf & _
"Drive = " & oFSO.getdrivename(filePath)
End Sub
I hope this helps you out.
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
|