Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
ASP FileSystemObject - Sorting & counting
Old 01-21-2009, 06:20 PM ASP FileSystemObject - Sorting & counting
tonya's Avatar
Ultra Talker

Posts: 485
Location: world traveller based in UK
Trades: 0
I want to quickly get a list of subfolders in a folder & also then the files in each folder.

I can get my list easy enough using a very basic script

Code:
<% 
    folder = "C:\" 
 
    set fso = CreateObject("Scripting.fileSystemObject") 
    set fold = fso.getFolder(folder) 
    for each file in fold.files 
        response.write file.name & "<br>" 
    next 
    set fold = nothing: set fso = nothing 
%>
How do I sort my files ???

Is there any easy way or do I need to put the results into a recordset. I have found some examples but some look really code intensive for something that should be I feel relatively simple.

Oh p.s if I want to count the files in the subfolder is there an easy way of doing that ???
__________________
Tonya

::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
 
Register now for full access!
Old 01-21-2009, 06:33 PM Re: ASP FileSystemObject - Sorting & counting
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Sorting files
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=118

counting the files
Code:
dim files, count
set files = fold.files
count = files.count
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-21-2009, 06:44 PM Re: ASP FileSystemObject - Sorting & counting
tonya's Avatar
Ultra Talker

Posts: 485
Location: world traveller based in UK
Trades: 0
Is there an easy way to apply that to the content of each subfolder ???

Code:
Dim iCurrentCell
folderspec = Server.MapPath("/graphics/.")
strPath=Server.MapPath ("/graphics/gallery/.") 
Set myFSO = Server.CreateObject("Scripting.FileSystemObject")
Set galleryFolder = myFSO.GetFolder(strPath)
Set folcoll = galleryFolder.SubFolders


Response.Write "The folders in the <b>" & galleryFolder.Name & "</b> Folder are: <br> <br>"%>
</p>

<%
For Each subfol in folcoll
Response.Write  "<a href='photos.asp?f=" & subfol.name & "'>" 
Response.write  subfol.Name & "</a><br/>"
Response.write ""
'iCurrentCell = iCurrentCell + 1
'If iCurrentCell > 2 then 
'Response.Write(" ")
'iCurrentCell=1
'End if
Next 

set myFSO = nothing
__________________
Tonya

::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
Old 01-21-2009, 06:44 PM Re: ASP FileSystemObject - Sorting & counting
tonya's Avatar
Ultra Talker

Posts: 485
Location: world traveller based in UK
Trades: 0
My workaround was to include a new FSO object that looked into & counted the content of each subfolder but that seems laborious for simply counting ?
__________________
Tonya

::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
tonya is offline
Reply With Quote
View Public Profile Visit tonya's homepage!
 
Reply     « Reply to ASP FileSystemObject - Sorting & counting
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12724 seconds with 12 queries