0

I'm trying to change the Label.text into the Name choose of the File that i'm going to save. This is the Code:

Dim saveDlg As SaveFileDialog = New SaveFileDialog
    saveDlg.Filter = "JPEG (*.jpeg)|*.jpeg |All Files |*.*"
    saveDlg.Title = "Save Picture"
    saveDlg.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
    Try
        If saveDlg.ShowDialog() = DialogResult.OK Then
            PictureBox1.Image.Save(saveDlg.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
            Txtfile.Text = saveDlg.FileName
            label14.text = ????? 
        End If
    Catch ex As Exception
        'Do Nothing
    End Try

i want to change the label text into the File saved names, i want show just the name and not the entire path.

Thanks to all in advance!

Valerio
  • 278
  • 1
  • 6
  • 18

1 Answers1

0

Use the Path.GetFileName(saveDlg.FileName) method.

cre8or
  • 387
  • 3
  • 10
  • Yes but this give me the name and extension of the Specified path string.. and the file can be saved in different path... i need something to change the text of my label wioth the name of the file just saved...maybe I'm making confusion but i don't think this method is what i need.. please help me to understand – Valerio May 08 '12 at 10:14
  • 1
    There must be some misunderstandings here :-) GetFileName is static method on class Path. For example: Path.GetFileName(@"C:\Program Files\myfile.txt") returns "myfile.txt". You could also use GetFileNameWithoutExtension() method. Does it help? – cre8or May 08 '12 at 10:43