|
-
Aug 17th, 2009, 03:27 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] File Name From Open File Dialog
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
I am still very new to VB.NET, so I have MANY questions
-
Aug 17th, 2009, 03:33 PM
#2
Re: File Name From Open File Dialog
To get only the name just use the IO namespace....
VB.NET Code:
IO.Path.GetFileName(file)
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Aug 17th, 2009, 03:37 PM
#3
Thread Starter
Hyperactive Member
Re: [RESOLVED] File Name From Open File Dialog
I am still very new to VB.NET, so I have MANY questions
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|