Getting the FileName

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SFlpm
    New Member
    • Feb 2007
    • 1

    #1

    Getting the FileName

    Hello, I was wondering, how do I get the actual file name of a file, I tried using
    Dim ofd As New OpenFileDialog
    ...
    If ofd.ShowDialog = Windows.Forms.D ialogResult.OK then

    'problem is here!
    label1.text = ofd.filename
    'problem is here!

    End if
    ...

    I would like it to just show the actual file that ofd opened, not the filepath, any ideas on this?

    Thanks,
    SFlpm
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    What version of VB is this? I can't even create an OpenFileDialog object, in VB6.

    Comment

    • Esmael
      New Member
      • Feb 2007
      • 58

      #3
      Hi...

      What reference did u add? what versioin VB?
      You can also use a Common Dialog Control if you want...

      Comment

      • TNT
        New Member
        • Feb 2007
        • 48

        #4
        Just chop the front of the filepath off until you get to the filename. Ltrim() would be a way of doing this.

        I think they are either running VisualBasic.NET or VisualBasic 2005.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by TNT
          Just chop the front of the filepath off until you get to the filename. Ltrim() would be a way of doing this.

          I think they are either running VisualBasic.NET or VisualBasic 2005.
          Unless it has changed considerably since I last used it, the LTrim() function just trims off leading spaces. How would that help?

          Comment

          Working...