ASP
Here you can find some FREE usefull Classic ASP / VBScript code snippets, class modules, etc.
Function GetFiles(String)String
Retrive a local folder's file list.
Example
Retuns a String with the file list. This list uses VB's Null char (Chr(0)) as the list separator. <% Dim i, folder_contents, item_array folder_contents = GetFiles("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 files found here" end if redim item_array(0): erase item_array %> Source Code <%
Function GetFiles(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.Files if GetFiles>"" then GetFiles = GetFiles & chr(0) GetFiles = GetFiles & itm.Name Next End If set itm = Nothing: set fld = Nothing: set fso = Nothing End Function %> |