Return FileName Only when using OpenFileDialog

后端 未结 8 808
孤独总比滥情好
孤独总比滥情好 2020-12-06 04:34

I am using the following method to browse for a file:

    OpenFileDialog.ShowDialog()
    PictureNameTextEdit.Text = OpenFileDialog.FileName
<
8条回答
  •  隐瞒了意图╮
    2020-12-06 04:45

    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.

提交回复
热议问题