Results 1 to 9 of 9

Thread: [RESOLVED] [2008] How to get folder names??

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Resolved [RESOLVED] [2008] How to get folder names??

    Hi, I'm trying to retrieve the names of X number of folders... I know that the names are strings, but i don't now how to get the names of, for example, 6 folders inside the "Group" folder.

    Any ideas??
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  2. #2
    New Member
    Join Date
    Feb 2009
    Posts
    3

    Re: [2008] How to get folder names??

    i assume you are willing to extract a folder from a full path which contains sub folders, am i right?

    it can be "hard coded" in a way such as this one:

    NOTE: in this example 'mypath' contains the path full of sub folders

    Code:
    dim Path_Arr as array                  ' this array will hold the folder names
    
    Path_Arr = split(mypath , "\")    ' split into folders and store in Path_Arr
    this will give you Path_Arr as an array filled up with the folder names given in the full path.

    e.g.

    if you input "c:\program files\microsoft\vb98"

    you are getting in Path_Arr:

    c: , program files , microsoft , vb98

    if i want for an example to extract the folder 'microsoft' from the array and
    output to a message box i'll write:

    Code:
    msgbox (Path_Arr(2) , vbOkOnly, "this folder")
    of course if you only want folders from a full path that might contain a file name and/or a drive name, you should figure out how to customize this simple routine to extract only folder names and exclude the rest.


    i'm pretty sure there are maybe better ways of doing this, but these are my 2cents.




    im new here btw :]

    had been programming under vb for over 6 years now, but only recently started upgrading my self into .NET

    P.S: the code was written directly into the reply, it was not tested on vb - but should %100 work.
    Last edited by dev_null84; Feb 28th, 2009 at 03:20 AM.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Re: [2008] How to get folder names??

    Thanks for your help! I think I can make it work with this! =DD
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  4. #4
    New Member
    Join Date
    Feb 2009
    Posts
    3

    Re: [2008] How to get folder names??

    you're welcome

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] How to get folder names??

    Hey,

    Just to add to this as well, if you are not already using it, think about using the System.IO.Directory class, here is a link to it's members:

    http://msdn.microsoft.com/en-us/libr..._members.aspx#

    Gary

  6. #6
    New Member
    Join Date
    Feb 2009
    Posts
    3

    Re: [2008] How to get folder names??

    gep: never used this before- thanks

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] How to get folder names??

    Hey,

    That would be the main access point for doing any manipulation or indexing of the FileSystem, so you may want to start looking into it. The equivalent for a File would be System.IO.File, here are it's members:

    http://msdn.microsoft.com/en-us/libr..._members.aspx#

    I would definitely recommend looking into them, as they already provide some of the functionality that you require.

    Another good one to look into is the System.IO.Path class, here:

    http://msdn.microsoft.com/en-us/libr..._members.aspx#

    Which includes methods such as GetExtension, GetDirectoryName etc.

    Hope this helps!!

    Gary

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Re: [2008] How to get folder names??

    @Gary:

    Thanks! I'll see how I can use this one!

    Thanks for the input!!
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] [2008] How to get folder names??

    No probs, happy to help

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