473,382 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Directory.GetDirectories display order

Can I control the order that files, folders are displayed? Can I do them
alphabetically or do I need to upload to a db like we did in asp?

items = Directory.GetDirectories(path)
For Each item In items
Response.Write(Replace(item, "F:\Inetpub\wwwroot\", "") & " <br
/>")
Next

Thanks
Mike
Nov 19 '05 #1
2 3501
Not pretty but it works

Public Function GetFolderInfo(ByVal strPath As String) As String
Dim item As String
Dim items() As String
Dim path As String = "F:\Inetpub\wwwroot\" & strPath

Dim arFolderArray As String

items = Directory.GetDirectories(path)

For Each item In items
arFolderArray = arFolderArray & Replace(item, path & "\", "") &
","
Next

Dim arFolder As Array
arFolderArray = Left(arFolderArray, Len(arFolderArray) - 1)

arFolder = Split(arFolderArray, ",")
Array.Sort(arFolder)
Dim x As Integer = 0

For x = 0 To UBound(arFolder)
Response.Write(arFolder(x) & " <br />")
Next
End Function

Mike

"Mike D" wrote:
Can I control the order that files, folders are displayed? Can I do them
alphabetically or do I need to upload to a db like we did in asp?

items = Directory.GetDirectories(path)
For Each item In items
Response.Write(Replace(item, "F:\Inetpub\wwwroot\", "") & " <br
/>")
Next

Thanks
Mike

Nov 19 '05 #2
Not pretty but it works

Public Function GetFolderInfo(ByVal strPath As String) As String
Dim item As String
Dim items() As String
Dim path As String = "F:\Inetpub\wwwroot\" & strPath

Dim arFolderArray As String

items = Directory.GetDirectories(path)

For Each item In items
arFolderArray = arFolderArray & Replace(item, path & "\", "") &
","
Next

Dim arFolder As Array
arFolderArray = Left(arFolderArray, Len(arFolderArray) - 1)

arFolder = Split(arFolderArray, ",")
Array.Sort(arFolder)
Dim x As Integer = 0

For x = 0 To UBound(arFolder)
Response.Write(arFolder(x) & " <br />")
Next
End Function

Mike

"Mike D" wrote:
Can I control the order that files, folders are displayed? Can I do them
alphabetically or do I need to upload to a db like we did in asp?

items = Directory.GetDirectories(path)
For Each item In items
Response.Write(Replace(item, "F:\Inetpub\wwwroot\", "") & " <br
/>")
Next

Thanks
Mike

Nov 19 '05 #3

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

Similar topics

1
by: Lee Holsenbeck | last post by:
hi, i am reading the directory structure into a treeview. when i select a new drive and do not have access to an existing folder; i get an acess denied - System.UnauthorizedAccessException...
0
by: Nick | last post by:
I am getting the following error when creating a new CacheDependency object: Failed to start monitoring changes to '\\server\share\dir49' This error happens after 48 successful instantiations of...
4
by: Elmo Watson | last post by:
Is there a way, with the System.IO class, to do a recursive list of a directory structure? For instance, in DirectoryInfo, you have GetDirectories and GetFiles .... In Directory, you have...
2
by: Manny Chohan | last post by:
Hi Guys, I am currently programming in Vb .net. I am stuck at point. i have a root directory C:\test which has couple of sub-folders c:\test\test1 ; c:\test\test2 ; c:\test\test1\test4 and so...
2
by: Martin | last post by:
Hi, I have implemeted a recursive function that basically iterate throught the entire file system and prints out the entire path of each directory that it come across. The only problem is the...
6
by: Regan Hurd | last post by:
Is there any way to copy a directory with the system.io namespace? Thanks
4
by: Brad | last post by:
I have been working on a class that moves files around and have come to a need to move an entire directory at one time. I thought that this would be really simple (some kind of CopyDirectory command)...
0
by: Carl Rapson | last post by:
I have some code that is checking a directory for subdirectories, using the Directory.GetDirectories method (I got this code from a sample app): Dim directories as String() Try directories =...
2
by: Nathan Sokalski | last post by:
I have an ASP.NET application which displays the directories & files in a specified directory on the server. I use the System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.