0

I use OpenFileDialog in VB.NET for importing file from C:\ , but when I choose my file , can I show ONLY the file name (not a complete path ) ? enter image description here

I want to see only namefile.pdf, and not c:....\namefile.pdf

Here is my code:

fichier.Filter = "PDF Files|*.pdf|image files|*.png;*.jpg;*.gif"
If fichier.ShowDialog = DialogResult.OK Then
   fichier_txt.Text = fichier.FileName
End If

fichier is OpenFileDialog name

boop_the_snoot
  • 3,209
  • 4
  • 33
  • 44
Zied.M
  • 215
  • 4
  • 17

1 Answers1

1

Use Path.GetFileName.

fichier.Filter = "PDF Files|*.pdf|image files|*.png;*.jpg;*.gif"
If fichier.ShowDialog = DialogResult.OK Then
   fichier_txt.Text = Path.GetFileName(fichier.FileName)
End If                            
boop_the_snoot
  • 3,209
  • 4
  • 33
  • 44
BladeMight
  • 2,670
  • 2
  • 21
  • 35