I am using the following method to browse for a file:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = OpenFileDialog.FileName
<
Suppose that I did select word2010 file named as "MyFileName.docx"
This is for ONLY the selected file extension "including the dot mark, f.e (.docx)"
MsgBox(System.IO.Path.GetExtension(Opendlg.FileName))
And this for the selected File name without extension: (MyFileName)
MsgBox(System.IO.Path.GetFileNameWithoutExtension(Opendlg.FileName))
and you can try the other options for the "PATH Class" like: GetFullPath,GetDirectoryName ...and so on.
Use SafeFileName instead of FileName and it will return a name (and extension) without path.
if you want just the selected name without Extension you can try this code
Imports System.IO
PictureNameTextEdit.Text = Path.GetFileNameWithoutExtension(OpenFileDialog1.FileName)
thanx
Use Path.GetFileName(fullPath) to get just the filename part, like this:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName)
Use this code to put the filename in PictureNameTextEdit:
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = OpenFileDialog.SafeFileName
OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName)