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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. FileName with Directory.GetFiles

FileName with Directory.GetFiles

Scheduled Pinned Locked Moved C#
data-structuresregextutorial
3 Posts 3 Posters 0 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
    Expert Coming
    wrote on last edited by
    #1

    I am using Directory.GetFiles to get an array of all the files in a directory. As far as that goes all is well. But, I need to know just the name of the files, not the whole path to the file. I was trying to us RegEx to search each file path and remove the path but I don't know how to do so universally as I don't know the exact path of the files all the time. Any ideas would be great. Thanks in advance!

    A A 2 Replies Last reply
    0
    • E Expert Coming

      I am using Directory.GetFiles to get an array of all the files in a directory. As far as that goes all is well. But, I need to know just the name of the files, not the whole path to the file. I was trying to us RegEx to search each file path and remove the path but I don't know how to do so universally as I don't know the exact path of the files all the time. Any ideas would be great. Thanks in advance!

      A Offline
      A Offline
      alexey N
      wrote on last edited by
      #2

      Use Path.GetFileName(String path). In namespace "Path" you can find many usefull functions :cool:

      1 Reply Last reply
      0
      • E Expert Coming

        I am using Directory.GetFiles to get an array of all the files in a directory. As far as that goes all is well. But, I need to know just the name of the files, not the whole path to the file. I was trying to us RegEx to search each file path and remove the path but I don't know how to do so universally as I don't know the exact path of the files all the time. Any ideas would be great. Thanks in advance!

        A Offline
        A Offline
        Aaron Dilliard
        wrote on last edited by
        #3

        OR you could just strip the directory info from the names... for(int i=0; i

        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