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
Printable View
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
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
I use common dialog I got this messagebox "C:\Project\D.tin"
dlgOpen.FileName
i want to get this C:\Project\
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