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?? :confused: :confused:
Printable View
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?? :confused: :confused:
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
this will give you Path_Arr as an array filled up with the folder names given in the full path.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
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:
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.Code:
msgbox (Path_Arr(2) , vbOkOnly, "this folder")
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.
Thanks for your help! I think I can make it work with this! =DD
you're welcome :)
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
gep: never used this before- thanks :)
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
@Gary:
Thanks! I'll see how I can use this one!
Thanks for the input!!
No probs, happy to help :)