[an error occurred while processing this directive] Home > Artwork > Photography > Photo Blog
<% ' In this demo, at least, we don't allow user to change directories... ' Change the DIRECTORY to point to any virtual directory of your choice. CONST DIRECTORY = "/" ' relative path in virtual directories ' Specify one of these constants for "sortBy"... CONST FILE_NAME = 0 CONST FILE_EXT = 1 CONST FILE_TYPE = 2 CONST FILE_SIZE = 3 CONST FILE_CREATED = 4 CONST FILE_MODIFIED = 5 '********** 'kc_fsoFiles 'Purpose: ' 1. To create a recordset using the FSO object and ADODB ' 2. Allows you to exclude files from the recordset if needed 'Use: ' 1. Call the function when you're ready to open the recordset ' and output it onto the page. ' example: ' Dim rsFSO, strPath ' strPath = Server.MapPath("\PlayGround\FSO\Stuff\") ' Set rsFSO = kc_fsoFiles(strPath, "_") ' The "_" will exclude all files beginning with ' an underscore '********** Function kc_fsoFiles(theFolder, Exclude) Dim rsFSO, objFSO, objFolder, File Const adInteger = 3 Const adDate = 7 Const adVarChar = 200 'create an ADODB.Recordset and call it rsFSO Set rsFSO = Server.CreateObject("ADODB.Recordset") 'Open the FSO object Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 'go get the folder to output it's contents Set objFolder = objFSO.GetFolder(theFolder) 'Now get rid of the objFSO since we're done with it. Set objFSO = Nothing 'create the various rows of the recordset With rsFSO.Fields .Append "Name", adVarChar, 200 .Append "Type", adVarChar, 200 .Append "DateCreated", adDate .Append "DateLastAccessed", adDate .Append "DateLastModified", adDate .Append "Size", adInteger .Append "TotalFileCount", adInteger End With rsFSO.Open() 'Now let's find all the files in the folder For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (right(File.Name, 3)) <> "asp" Then rsFSO.AddNew rsFSO("Name") = File.Name rsFSO("Type") = File.Type rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next 'And finally, let's declare how we want the files 'sorted on the page. In this example, we are sorting 'by File Type in descending order, 'then by Name in an ascending order. rsFSO.Sort = "DateCreated DESC, DateLastModified DESC " 'Now get out of the objFolder since we're done with it. Set objFolder = Nothing 'now make sure we are at the beginning of the recordset 'not necessarily needed, but let's do it just to be sure. rsFSO.MoveFirst() Set kc_fsoFiles = rsFSO End Function Dim arrHeaders(35) Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace("D:\SWsoft\PEM\CustomerData\webspaces\webspace_00052323\wwwroot\artwork\photography\blog\") For i = 9 to 14 arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i) Next 'Now let's call the function and open the recordset on the page 'the folder we will be displaying Dim strFolder : strFolder = Server.MapPath("\artwork\photography\blog\") 'the actual recordset we will be creating with the kc_fsoFiles function Dim rsFSO 'now let's call the function and open the recordset 'we will exclude all files beginning with a "_" Set rsFSO = kc_fsoFiles(strFolder, "_") 'now we'll create a loop and start displaying the folder 'contents with our recordset. Of course, this is just a 'simple example and not very well formatted, i.e., not in 'a table, but it gets the point across on how you can 'ouput the recordset on the page. While not rsFSO.eOF dim photodate photodate=rsFSO("DateLastModified") %> <% For Each strFileName in objFolder.Items if right(strFileName,8) = left(rsFSO("Name").Value,8) then 'For i = 9 to 14 dim photowidth photowidth = objFolder.GetDetailsOf(strFileName, 26) dim orientationwidth dim orientationhieght if left(photowidth,3) > right(photowidth,3) then orientationwidth = 200 else orientationwidth = 150 if left(photowidth,3) < right(photowidth,3) then orientationhieght = 200 else orientationhieght = 150 %> <% 'and let's move to the next record rsFso.MoveNext() Wend 'finally, close out the recordset rsFSO.close() Set rsFSO = Nothing %>
" width ="<%=orientationwidth%>" height="<%=orientationhieght%>" border="0" class="imageborder"> <%= left(photodate, 10)%> <% response.write("
") response.write(objFolder.GetDetailsOf(strFileName, 10)) response.write("
") response.write(objFolder.GetDetailsOf(strFileName, 14)) 'Next End if Next %>

These images are copyright protected.

[an error occurred while processing this directive]