473,794 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Nested Folder Depth?

Hi,

Is there any easy way to get the number of nested folders for a given path.
for instance I have the following

(trying my best to simulate a view you would see in windows explorer)
c:\temp
\folder1a
\folder1b
\folder2a
\folder1c
\folder2a
\folder3a
\folder2b

If I gave this "function" an input of "c:\temp" it would return 3, since the
most nested folder is 3 levels beneath it (\folder3a). Anyway to do this?

Thanks,
--Michael
Nov 20 '05 #1
2 2660
you could count the occurances of the \ in the string the path returns...
"Michael Ramey" <raterus@localh ost> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

Is there any easy way to get the number of nested folders for a given path. for instance I have the following

(trying my best to simulate a view you would see in windows explorer)
c:\temp
\folder1a
\folder1b
\folder2a
\folder1c
\folder2a
\folder3a
\folder2b

If I gave this "function" an input of "c:\temp" it would return 3, since the most nested folder is 3 levels beneath it (\folder3a). Anyway to do this?

Thanks,
--Michael

Nov 20 '05 #2
Just made this, seems to work. Does it recursively

Private Function getDirectoryDep th(ByVal currentPath As String, ByVal
depth As Integer) As Integer
Dim folders() As String = Directory.GetDi rectories(curre ntPath)
Dim curFolder As String
Dim thisDepth As Integer, maxDepth As Integer

maxDepth = depth

For Each curFolder In folders
thisDepth = getDirectoryDep th(curFolder, depth + 1)

If thisDepth > maxDepth Then
maxDepth = thisDepth
End If
Next

Return maxDepth

End Function
"Michael Ramey" <raterus@localh ost> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

Is there any easy way to get the number of nested folders for a given path. for instance I have the following

(trying my best to simulate a view you would see in windows explorer)
c:\temp
\folder1a
\folder1b
\folder2a
\folder1c
\folder2a
\folder3a
\folder2b

If I gave this "function" an input of "c:\temp" it would return 3, since the most nested folder is 3 levels beneath it (\folder3a). Anyway to do this?

Thanks,
--Michael

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
3983
by: Jeff Lanfield | last post by:
First of all, I apologize if coalescing is not the right term to describe my problem. I have a tree where each node has the same set of attributes (is the same entity) but child nodes should inherit attribute values from parent node. for example, say I have the following table: (nodeId int , color varchar, phone varchar) with two rows 5, "GREEN", "555-1212"
6
2184
by: oooooo0000000 | last post by:
I have an XML file of varying nesting depth... <catalouge> <item id="1"> <name/> <item id="23"> <name/> <item id="55"> <name/> </item>
12
3994
by: coosa | last post by:
Dear all, I have table called CATEGORY, which is defined as follows: CREATE TABLE CATEGORY ( CATEGORY_ID INTEGER IDENTITY(1,1) NOT NULL, CATEGORY_NAME VARCHAR(40) NOT NULL CONSTRAINT UC__CATEGORY__CATEGORY_NAME UNIQUE, PARENT_CATEGORY_ID INTEGER,
3
1706
by: Rolf Welskes | last post by:
Hello, for a large web site project we would like to use nested Master Pages. Unfortunely VS2005 is not able to show pages in design mode when nested Master pages are used. This has the consequence that also each content page cannot be used in design mode. It is impossible to design hundrets of pages in source mode without design
0
1196
by: hungrymind | last post by:
Hi all, I am developing web application as well as mobile application using C# asp.net 2.0. Mobile application folder is nested inside web application virtual directory. I have to make mobile folder as virtual directory to have web.config. This is because i have to modify "sessionState" key inside mobile folder so that cookieless session can be enabled. Is there any way to avoid creation of virtual folder can be avoided for mobile...
3
2645
by: CrazyAtlantaGuy | last post by:
I am working on creating an XSLT that transforms Html into an XML format that can be imported into Framemaker. The challenge, it turns out, is correctly transforming the flat html header tags (<H1>, <H2>, etc) into nested sections inside the xml. I have made significant progress, but have run into a roadblock. Here is an example of my input HTML: <html><body>
2
11267
by: Gentr1 | last post by:
Hi everybody! I am presently working on a Genetic Programming API in python. I have a bit of a problem at the moment... For some specific reasons, I am using nested lists data structure to represent a tree. The first element of a list is always the head of the node, while all others represent the tail of the node. e.g. the nested list , E], ] represent the following tree: http://www.csd.abdn.ac.uk/~mkhoury/tree.jpg I need to be able...
2
1753
by: puzzlecracker | last post by:
How will this actually work: public class Foo<T> { public class Bar<T> { private T t; }
25
3541
mshmyob
by: mshmyob | last post by:
I am in testing mode for this part of my app so I can change anything to make this work. I have added email functionality to one of my apps. I use SMTP to send and either POP3 or IMAP4 to receive. For the receive I store everything into tables except attachments - they are in a directory and only referenced in the tables. Everything works fine so no problem getting email to work. What I am wanting has to do with the interface. ...
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.