16. december 2003 - 18:05Der er
10 kommentarer og 1 løsning
Vis antal filer i mappen + Vis størrelse på filer
egentligt er spørgsmålet en fortsættelse på et svar Som eagleeye kom med i et tidligere spørgsmål:
jeg vil gerne i følgende scripts få vist hvor mange filer der ligger i undermapperne,
<% sti = "Cars" ShowSub = sti & request("ShowSub") ShowSubLink = request("ShowSub") strPathInfo = ShowSub strPhysicalPath = Server.MapPath(strPathInfo)
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPhysicalPath)
For each Folder in objFolder.SubFolders If Left(Folder.Name,1)<>"_" Then Response.Write "<a href=""" & CurFile & "?ShowSub=" & ShowSubLink & "/" Response.Write(Replace(Folder.Name, " ", "%20")) response.write """>" Response.Write Folder.Name Response.Write "<br>" End if Next
Set objFSO = Nothing %>
Desuden vist størrelsen på filerne i dette script :
If ShowSub > " " then ShowSub = Replace(ShowSub, " ", "%20") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPhysicalPath) Set objFolderContents = objFolder.Files For Each objFileItem in objFolderContents Response.write "<tr><td>" if InStr(1,"jpg,bmp,gif", LCase(objFSO.GetExtensionName(objFileItem.name))) > 0 then Response.Write "<a href=""" & ShowSub & "/" & objFileItem.Name &""">" & objFileItem.Name & "</a>" End if Response.write "</td></tr>" Next Set objFSO = Nothing End if %>
Poster lige det her for jeg selv kan finde det en anden gang :
Hmmm, ran into the same problem and discovered that I was wrong in my post above. After some research, and much pulling of hair, I discover that Access ALWAYS saves dates in MM/DD/YYY format, something I did not know. So searching for a record with today's date can cause problems if you are on the this side of the pond.
The solution I came up with which seems to work is to force the date thus:-
sti = startpath ShowSub = sti & request("ShowSub") ShowSubLink = request("ShowSub") strPathInfo = ShowSub strPhysicalPath = Server.MapPath(strPathInfo)
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPhysicalPath)
For each Folder in objFolder.SubFolders Set oSub = CreateObject("Scripting.FileSystemObject") Set oFolder = oSub.GetFolder(strPhysicalPath & "\" & Folder.name) Set oFolderContents = oFolder.Files For Each oFileItem in oFolderContents oFiles = oFiles + 1 Next Response.Write oFiles Next
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.