Results 1 to 4 of 4

Thread: [RESOLVED] Get Folder Name

  1. #1

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Resolved [RESOLVED] Get Folder Name

    I have this path:

    C:\SomeFolder\Folder1\file.txt

    How do I get the name "Folder1"?
    There are no GetFolderName function, only directory name

  2. #2
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Get Folder Name

    A "Directory" is what we use to call a folder back before GUIs came along with their desktop metaphor.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Get Folder Name

    Path.GetFileName gets the leaf node from the path and Path.GetDirectoryName gets the rest. Call GetDirectoryName first to trim off the last node and create a new path, then call GetFileName to get the last node of that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: Get Folder Name

    Thank you, it worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width