Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to get file name from openfiledialog without file path

How to get file name from openfiledialog without file path

Scheduled Pinned Locked Moved Visual Basic
csharptutorialquestion
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ejaz_pk
    wrote on last edited by
    #1

    How I can get the filename from the openfiledialog without the full path? I have filename as in openfiledialog "C:\Upload\trp.txt" I want Only "trp.txt". How this can be done by vb.net 2005? THanks in advance

    J A 2 Replies Last reply
    0
    • E ejaz_pk

      How I can get the filename from the openfiledialog without the full path? I have filename as in openfiledialog "C:\Upload\trp.txt" I want Only "trp.txt". How this can be done by vb.net 2005? THanks in advance

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      There is a better way to do it, I am sure. And perhaps someone else will also answer your question with this better solution, but here is the one that I remember using once: Dim backslash As Char = "\" TxtFileName.Text = "" OFD.ShowDialog() TxtFileName.Text = OFD.FileName.Substring(OFD.FileName.LastIndexOf(backslash) + 1)

      My advice is free, and you may get what you paid for.

      1 Reply Last reply
      0
      • E ejaz_pk

        How I can get the filename from the openfiledialog without the full path? I have filename as in openfiledialog "C:\Upload\trp.txt" I want Only "trp.txt". How this can be done by vb.net 2005? THanks in advance

        A Offline
        A Offline
        Ashfield
        wrote on last edited by
        #3

        Imports System.IO With OpenFileDialog1 .Title = "Get File Name" .ShowDialog() myFileName = Path.GetFileName(.FileName) End With

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups