| bod1467 on Mar 30, 2006 at 11:37:40 PM (# 25) Here's an example that gets all the files in a folder and stores them in a recordset (NOT a database) ...
<% @ LANGUAGE=VBSCRIPT %> <% Option Explicit Response.Expires = -1000 Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const adVarChar = 200, adOpenDynamic = 2, adFldUpdatable = &H00000004, adInteger = 3, adDate = 7 Dim f, fso, path, fldr, fldrs, thisfldr, fls, rs, count, i, orderby, passwd, showOK
orderby = Request.querystring("OrderBy") If orderby = "" Then orderby = "FileName"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Fields.Append "FileName", adVarChar, 100, adFldUpdatable rs.Fields.Append "FileType", adVarChar, 40, adFldUpdatable rs.Fields.Append "FileSize", adInteger, 40, adFldUpdatable rs.Fields.Append "LastMod", adDate, 40, adFldUpdatable rs.Open , , adOpenDynamic
path = Request.Servervariables("PATH_TRANSLATED") path = StrReverse(path) path = Mid(path,InStr(path,"\"),Len(path)) path = StrReverse(path)
Set fso = CreateObject("Scripting.FileSystemObject") Set fldr = fso.getFolder(path) Set fldrs = fldr.subFolders
For each thisfldr in fldrs rs.AddNew rs("FileName") = thisfldr.Name rs("FileType") = thisfldr.Type rs("FileSize") = thisfldr.Size rs("LastMod") = thisfldr.DateLastModified rs.Update Next 'thisfldr
Set fls = fldr.Files For each f in fls rs.AddNew rs("FileName") = f.Name rs("FileType") = f.Type rs("FileSize") = f.Size rs("LastMod") = f.DateLastModified rs.Update Next 'f
Select Case orderby Case "FileName" rs.Sort = "FileName" Case "FileType" rs.Sort = "FileType" Case "FileSize" rs.Sort = "FileSize" Case "LastMod" rs.Sort = "LastMod" Case Else rs.Sort = "FileName" End Select
rs.MoveFirst %>
You can then use the recordset how you want. \o/ RobinAnn on Apr 3, 2006 at 8:31:19 PM (# 26)I must be DUH bcas I tried both and got nil. You can check out www.robin-ann.net/images and www.robin-ann.net/images/go.vbs to see what I did - if you want to. Winterwolf on Apr 4, 2006 at 1:43:26 PM (# 27)RobinAnn: I suspect you did not place the code I gave you in an asp file. that would be why I can see the <%= and %> tags in the source. And probably why the code didnt do what you expected. ChrisRickard on Apr 4, 2006 at 1:48:06 PM (# 28)And are you running IIS? RobinAnn on Apr 4, 2006 at 6:36:42 PM (# 29)Chris - What's IIS? Is that like BachusII? ;-)
Winterwolf - oopsie
BachusII on Apr 4, 2006 at 11:42:06 PM (# 30)Hey now, that's an offensive remark. I don't go around calling you names, do I? MHenke on Apr 5, 2006 at 1:10:55 AM (# 31)LOL, that's forsooth an inadequate comparison, I'd bet. Two completely incompatible technologies... 8)
|