I want to get the selected folder path
dlgBrowse.ShowOpen
fname = dlgBrowse.FileName
dlgBrowse.Filter = "Text File (*.txt)|*.txt|Log File (*.log)|*.log||All Files (*.*)|*.*"
dlgBrowse.DialogTitle = "Open Log File"
dlgBrowse.ShowOpen
If dlgBrowse.FileName <> "" Then
txtLogFile.Text = dlgBrowse.FileName
End If
MsgBox fname
This shows the output "C:\MRMS\Report\xyz.txt"
, but I want only the selected folder path, ie if the user selects only root(MRMS) folder i.e. "C:\MRMS"
or any other folder only up to user selected folder.
The shortest way:
Dim FullPath as string, ParentFolder as string, l() as string
FullPath = "" '... Write here the path from ComDlg
l = Split(FullPath, "\")
l(UBound(l)) = ""
ParentFolder = Join(l, "\")