ASP

The XML Document Object Model

0

I’m writing a bunch of functions that communicate with Amazon using classic asp, it requires me to learn much more about the XMLDOM, so that I don’t manually parse through every XML file. For anyone else who is interested in the XMLDOM I recommend the article, “XML“, over at Dev Articles who, by the way, tend to produce many many very helpful and articulate articles written in a manner most people can either understand or learn to understand.

JJ

How To Do a Search Through Folders – Two Levels Deep

0

I used the following code to search through my “galleries” folder and search for images through every folder inside galleries sub-folders.

Huh?

I used each folder inside of galleries as the “category” for each set of images. What it ended up doing was this. Each time I wanted to create a new category I would just make a new folder inside of “galleries”, each time I wanted a new album I’d put another folder inside each category folder. For example I could have a folder structure as follows:
/galleries
—/wedding
——-/getting_ready
——-/court_house
——-/reception
—/first_home
——-/before
——-/after

As you can see my categories are under galleries and they are called “wedding” and “first_home”. My galleries are called “getting_ready”, “court_house”, “reception”, “before” and “after”.

Oh I see!

I’m not going to be releasing the code to the entire program because an ex co-worker of mine and I plan on selling a gallery solution based on this, but here is the code for the folder searching! It is possible to modify this to do a full recursive search, I’ve done it before. Try creating another folder search function, while building the folder path you are passing into the functions as you go. It’s possible to build a recursive output that will show every file in an entire site directory, if you set root_folder = “/”

The Code

root_folder = “/galleries/”
SearchFolders root_folder

Sub SearchFolders(root_folder)
set FileSysObj=CreateObject(“Scripting.FileSystemObject”)
strFullPath = server.mappath(root_folder)
set fldr=FileSysObj.GetFolder(strFullPath)
set FolderList = fldr.SubFolders
For Each FolderIndex in FolderList
Response.Write(FolderIndex.name & ”
“)
Next
set FileList = fldr.Files
For Each FileIndex in FileList
Response.Write(FileIndex.name & ”
“)
Next
End Sub

Sub DisplaySubFolders(root_folder, parent_folder)
set FileSysObj=CreateObject(“Scripting.FileSystemObject”)
strFullPath = server.mappath(root_folder)
set fldr=FileSysObj.GetFolder(strFullPath)
set FolderList = fldr.SubFolders
For Each FolderIndex in FolderList
Response.Write(FolderIndex.name & ”
“)
Next
set FileList = fldr.Files
For Each FileIndex in FileList
Response.Write(FileIndex.name & ”
“)
Next
End Sub

Enjoy,
JJ

Go to Top