I am using this, to read 1+ files from the openFileDialog, but I am having a problem getting just the file name, I can get the location "C:\My Documents\filename.jpg" but how do I get just the name "filename.jpg"?
I want to replace it with this line: can.Text = Regex.Replace(file, ".+\\$", "")
vb.net Code:
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click Dim files openFile.InitialDirectory = "C:\" If openFile.ShowDialog = Windows.Forms.DialogResult.OK Then files = openFile.FileNames Dim f Dim i = 0 For Each file In files Dim can As New Canvas f = Image.FromFile(file) can.contCanvas.Width = f.Width can.contCanvas.Height = f.Height can.MdiParent = Me can.Text = Regex.Replace(file, ".+\\$", "") Dim h = f.Height, w = f.Width can.ClientSize = New Size(w, h) can.Show() Dim layer = New Layer("layer0", can.contCanvas, can.mnu) layer.setImage(f) i += 1 Next End If End Sub




Reply With Quote