ASP
Here you can find some FREE usefull Classic ASP / VBScript code snippets, class modules, etc.
Function GetFolders(String)String
Retrive a local folder's sub-folder list.
Example
Retuns a String with the sub-folder list. This list uses VB's Null char (Chr(0)) as the list separator. <% Dim i, folder_contents, item_array folder_contents = GetFolders("myfolder/mysubfolder") ' use relative or absolute paths if folder_contents>"" then item_array = split(folder_contents, Chr(0)) for i = 0 to ubound(item_array) response.write item_array(i) & "<br>" next else response.write "No sub-folders found here" end if redim item_array(0): erase item_array %> Source Code <%
Function GetFolders(foldername) dim fso, folderpath, fld, itm if mid(foldername,2,1)<>":" and left(foldername,2)<>"\\" then folderpath = Server.MapPath(foldername) else folderpath = foldername set fso=server.createobject("scripting.filesystemobject") If fso.FolderExists(folderpath) Then Set fld = fso.GetFolder(folderpath) For Each itm In fld.SubFolders if GetFolders>"" then GetFolders = GetFolders & chr(0) GetFolders = GetFolders & itm.Name Next End If set itm = Nothing: set fld = Nothing: set fso = Nothing End Function %> |