|
-
Jan 12th, 2008, 04:22 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] how to get path location
I used common dialog, How I can get the path location of my file?
Code:
dlgOpen.Filter = "Tin Files (*.tin)|*.tin"
dlgOpen.ShowOpen
InputFileTIN = dlgOpen.FileName
MsgBox dlgOpen.FileName
-
Jan 12th, 2008, 04:31 AM
#2
Re: how to get path location
There's a few ways, ie using Split with "\" as the delimiter, APIs and:
vb Code:
Private Sub Form_Load()
MsgBox GetDirectoryFromPath("E:\VideoPaper\Videos\Atomic Kitten - Whole Again.mpg")
MsgBox GetFilenameFromPath("E:\VideoPaper\Videos\Atomic Kitten - Whole Again.mpg")
End Sub
Public Function GetDirectoryFromPath(FullPath As String) As String
'Returns "E:\VideoPaper\Videos\".
GetDirectoryFromPath = Left(FullPath, InStrRev(FullPath, "\"))
End Function
Public Function GetFilenameFromPath(FullPath As String) As String
'Returns "Atomic Kitten - Whole Again.mpg".
GetFilenameFromPath = Right(FullPath, Len(FullPath) - InStrRev(FullPath, "\"))
End Function
-
Jan 12th, 2008, 04:38 AM
#3
Thread Starter
Frenzied Member
Re: how to get path location
I use common dialog I got this messagebox "C:\Project\D.tin"
dlgOpen.FileName
i want to get this C:\Project\
-
Jan 12th, 2008, 04:43 AM
#4
Re: how to get path location
Using the code above:
vb Code:
Option Explicit
Private Sub Form_Load()
Dim strFN As String
CommonDialog.Filter = "All Files (*.*)|*.*"
CommonDialog.ShowOpen
strFN = CommonDialog.FileName
MsgBox CommonDialog.FileName
MsgBox GetDirectoryFromPath(CommonDialog.FileName)
End Sub
Public Function GetDirectoryFromPath(FullPath As String) As String
GetDirectoryFromPath = Left(FullPath, InStrRev(FullPath, "\"))
End Function
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
|