|
-
Feb 28th, 2009, 01:05 AM
#1
Thread Starter
Fanatic Member
-
Feb 28th, 2009, 03:15 AM
#2
New Member
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.
-
Feb 28th, 2009, 03:21 AM
#3
Thread Starter
Fanatic Member
Re: [2008] How to get folder names??
Thanks for your help! I think I can make it work with this! =DD
-
Feb 28th, 2009, 03:30 AM
#4
New Member
Re: [2008] How to get folder names??
you're welcome
-
Feb 28th, 2009, 03:58 AM
#5
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
-
Feb 28th, 2009, 04:02 AM
#6
New Member
Re: [2008] How to get folder names??
gep: never used this before- thanks
-
Feb 28th, 2009, 04:18 AM
#7
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
-
Feb 28th, 2009, 10:11 AM
#8
Thread Starter
Fanatic Member
Re: [2008] How to get folder names??
@Gary:
Thanks! I'll see how I can use this one!
Thanks for the input!!
-
Feb 28th, 2009, 10:26 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|