Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is there any way to just get the filename without the path? example:

 

you select file to open and click Open, it then puts the filename without the path like C:\blah\blah.ext it will put blah.ext

 

anyone know?

Page Edit 2.0 Alpha 2 OUT NOW!

- Download Now -

  • Administrators
Posted

Once you have the full path you coul just use the Path class to break it down.

       Dim FullPath As String
       Dim FileNameOnly As String
       If OpenFileDialog1.ShowDialog = DialogResult.OK Then
           FullPath = OpenFileDialog1.FileName
           FileNameOnly = System.IO.Path.GetFileName(FullPath)
       End If

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
oh... since this topic is about the opendialog, i guess i could insert my question here as well. how come when the opendialogbox opens and i click the cancel button, the even causes an error. and for example i clicked the file that i want to open in the dialog box, but decided to not open it anymore (click the cancel button), the file is still open (assuming that my application opens files and views it in the application).
Posted

try this:

 

       OpenFileDialog.Title = ("Open File")
       OpenFileDialog.Filter = ("Text File (*.txt)|*.txt")

       If OpenFileDialog.ShowDialog() = DialogResult.OK Then
               'Open file
       End If

Page Edit 2.0 Alpha 2 OUT NOW!

- Download Now -

  • Leaders
Posted
I don't know if this is a property of the OpenFileDialog in .Net, but in the ActiveX version there is an property that is something like ErrorOnCancel to give you an option to throw an error when the user hits cancel.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...