Skal du bare indsætte flere rækker i recordsettet: Set objFolder = objFSO.GetFolder(server.mapPath("\PlayGround\FSO\stuff\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("\PlayGround\FSO\OtherStuff\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("\PlayGround\FSO\WayOtherStuff\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next
Det kunne så med fordel smides i en funktione i stedet, så det ikke fylder så meget. Du skal måske også have gemt en sti i recordsettet, så du kan se hvor de enkelte filer kommer fra.
<% '********** '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(server.mapPath("\.\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("\bib1\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("\bbib2\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next
'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 (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if 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 " rsFSO.Filter = "Type <> 'zip' and Type <> 'asp'"
'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
'Now let's call the function and open the recordset on the page 'the folder we will be displaying Dim strFolder : strFolder = Server.MapPath(".")
'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. count = 0 While Not rsFSO.EOF and count < 10 %> <p><%= rsFSO("Name").Value %> | <%= rsFSO("Type").Value %></p> <% 'and let's move to the next record rsFso.MoveNext() count = count + 1 Wend
'finally, close out the recordset rsFSO.close() Set rsFSO = Nothing %>
<% '********** '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")
'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()
'go get the folder to output it's contents Set objFolder = objFSO.GetFolder(server.mapPath("\.\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("\bib1\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("\bbib2\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if 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 " rsFSO.Filter = "Type <> 'zip' and Type <> 'asp'"
'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
'Now let's call the function and open the recordset on the page 'the folder we will be displaying Dim strFolder : strFolder = Server.MapPath(".")
'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. count = 0 While Not rsFSO.EOF and count < 10 %> <p><%= rsFSO("Name").Value %> | <%= rsFSO("Type").Value %></p> <% 'and let's move to the next record rsFso.MoveNext() count = count + 1 Wend
'finally, close out the recordset rsFSO.close() Set rsFSO = Nothing %>
<% '********** '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")
'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()
'go get the folder to output it's contents Set objFolder = objFSO.GetFolder(server.mapPath("\.\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("\bib1\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("\bbib2\")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if 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 " rsFSO.Filter = "Type <> 'zip' and Type <> 'asp'"
'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
'Now let's call the function and open the recordset on the page 'the folder we will be displaying Dim strFolder : strFolder = Server.MapPath(".")
'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. count = 0 While Not rsFSO.EOF and count < 10 %> <p><%= rsFSO("Name").Value %> | <%= rsFSO("Type").Value %></p> <% 'and let's move to the next record rsFso.MoveNext() count = count + 1 Wend
'finally, close out the recordset rsFSO.close() Set rsFSO = Nothing %>
jeg tror jeg har løst det - jeg skal bare sætte count til det antal biblioteker jeg henter fra, så bliver de jo sorteret efter dato og henter de sidste 5 filer, - ik?
Tror jeg misforstod dig tidligere. Jeg hvade forstået det som om det bare var de x nyeste filer. Men du vil have den nyeste fil fra hver mappe. Altså 1 fil fra hver mappe...
Så skal hele koden gentages. Laver lige en funktion i stedet... 2 sek.
Nå det dur ikke alligevel - jeg smider lige koden på - i 8 sidste linie hvor jeg laver listen som links fejler koden idet filen her ligger ikke isamme biblioteker som filerne bliver listet fra - hvis du forstår - linket kommer til at være placeringen hvor denne fil ligger plus filnavnet fra et andet bibliotek og så virker linket jo ikke, - vel??? <% '********** '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(server.mappath("."))
'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()
'go get the folder to output it's contents Set objFolder = objFSO.GetFolder(server.mapPath("bib1")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("bib2")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("bib3")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("../analyse/berigelse/Pengeskabstyveri")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("bib4")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next Set objFolder = objFSO.GetFolder(server.mapPath("bib5")) For Each File In objFolder.Files 'hide any file that begins with the character to exclude If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if 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 " rsFSO.Filter = "Type <> 'zip' and Type <> 'asp' and Type <> 'jpg' and Type <> 'txt' and Type <> 'html'"
'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
'Now let's call the function and open the recordset on the page 'the folder we will be displaying Dim strFolder : strFolder = Server.MapPath(".")
'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. count = 0 While Not rsFSO.EOF and count < 6
Så har jeg lavet denne funktion. Skulle kunne bruges til næsten alt:
<%
function getFilesInArr(fFolder,fArray,fAmount,fFilter,fSort) Dim rsFSO, objFSO, objFolder, File, fCount Const adInteger = 3 Const adDate = 7 Const adVarChar = 200 redim fArray(6,0) Set rsFSO = Server.CreateObject("ADODB.Recordset") Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(server.mapPath(fFolder)) Set objFSO = Nothing 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()
For Each File In objFolder.Files If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next if fSort <> "" then rsFSO.Sort = fSort end if if fFilter <> "" then rsFSO.Filter = fFilter end if Set objFolder = Nothing rsFSO.MoveFirst() fCount = 0 while not rsFSO.eof and (fCount < fAmount or fAmount=0) redim preserve fArray(6,fCount) fArray(0,fCount) = rsFSO("name") fArray(1,fCount) = rsFSO("Type") fArray(2,fCount) = rsFSO("DateCreated") fArray(3,fCount) = rsFSO("DateLastAccessed") fArray(4,fCount) = rsFSO("DateLastModified") fArray(5,fCount) = rsFSO("Size") rsFSO.MoveNext fCount = fCount + 1 wend end function
dim arr
call getFilesInArr("Mappe1", arr, 1, "Type <> 'zip' and Type <> 'asp' and Type <> 'jpg' and Type <> 'txt' and Type <> 'html'", "DateCreated DESC ") for f=0 to ubound(arr,2) Response.write arr(0,f) &"<br>" next
call getFilesInArr("Mappe2", arr, 1, "Type <> 'zip' and Type <> 'asp' and Type <> 'jpg' and Type <> 'txt' and Type <> 'html'", "DateCreated DESC ") for f=0 to ubound(arr,2) Response.write arr(0,f) &"<br>" next
%>
Fil data bliver loaded over i et array, som er sendt med som parameter, så man selv kan bestemme hvad det skal hedde. Sortering og filter sendes også med, så man kan bestemme dem. Hvis antalet af filer man vil have tilbage sættes til 0 returneres alle filer.
Det klare du via udskriften. Der ved du jo hvilken mappe du har hentet:
call getFilesInArr("Mappe2", arr, 1, "Type <> 'zip' and Type <> 'asp' and Type <> 'jpg' and Type <> 'txt' and Type <> 'html'", "DateCreated DESC ") for f=0 to ubound(arr,2) Response.write "<a href=""Mappe2/"& arr(0,f) &""">"& arr(0,f) &"</a><br>" next
jeg er stadig ikke helt med - hvordan får jeg funktionen til at gå ned i de 4 mapper - skal jeg kopiere funktionen 4 gange og ændre sti til biblioteket og med selve udskriften - der hvor du kriver mappe2 hvad skal der stå der??
Nej, du kalder funktionen med mappe navnet. Din kode vil blive noget ala:
function getFilesInArr(fFolder,fArray,fAmount,fFilter,fSort) Dim rsFSO, objFSO, objFolder, File, fCount Const adInteger = 3 Const adDate = 7 Const adVarChar = 200 redim fArray(6,0) Set rsFSO = Server.CreateObject("ADODB.Recordset") Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(server.mapPath(fFolder)) Set objFSO = Nothing 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()
For Each File In objFolder.Files If (Left(File.Name, 1)) <> Exclude Then rsFSO.AddNew rsFSO("Name") = File.Name if instr(File.Name,".") then rsFSO("Type") = mid(File.Name,instrrev(File.Name,".")+1) else rsFSO("Type") = "" end if rsFSO("DateCreated") = File.DateCreated rsFSO("DateLastAccessed") = File.DateLastAccessed rsFSO("DateLastModified") = File.DateLastModified rsFSO("Size") = File.Size rsFSO.Update End If Next if fSort <> "" then rsFSO.Sort = fSort end if if fFilter <> "" then rsFSO.Filter = fFilter end if Set objFolder = Nothing rsFSO.MoveFirst() fCount = 0 while not rsFSO.eof and (fCount < fAmount or fAmount=0) redim preserve fArray(6,fCount) fArray(0,fCount) = rsFSO("name") fArray(1,fCount) = rsFSO("Type") fArray(2,fCount) = rsFSO("DateCreated") fArray(3,fCount) = rsFSO("DateLastAccessed") fArray(4,fCount) = rsFSO("DateLastModified") fArray(5,fCount) = rsFSO("Size") rsFSO.MoveNext fCount = fCount + 1 wend end function
dim arr
'Hent filer fra bib1 call getFilesInArr("bib1", arr, 1, "Type <> 'zip' and Type <> 'asp' and Type <> 'jpg' and Type <> 'txt' and Type <> 'html'", "DateCreated DESC ") 'Udskriv filerne i arrayet for f=0 to ubound(arr,2) Response.write "<a href=""bib1/"& arr(0,f) &""">"& arr(0,f) &"</a><br>" next
'Hent filer fra bib2 call getFilesInArr("bib2", arr, 1, "Type <> 'zip' and Type <> 'asp' and Type <> 'jpg' and Type <> 'txt' and Type <> 'html'", "DateCreated DESC ") 'Udskriv filerne i arrayet for f=0 to ubound(arr,2) Response.write "<a href=""bib2/"& arr(0,f) &""">"& arr(0,f) &"</a><br>" next ... ...
Den dur bare ikke med de nye filnavne som har 4 tegn i extensions. Jeg kan så ikke forstå hvorfor den anden ikke virker for dig. Jeg har smidt den på eksemplet på mit site (post 13/07-2007 13:33:26), og der virker det fint. Skulle dog lige en -1 på for at fjerne punktumet.
nu drejer det sig kun om pdf filer og jpg filer, så det går - jeg laver lige et nyt spm - jeg vil gerne se alle filerne i bibliotekerne - det må være samme script - næsten??
Synes godt om
Ny brugerNybegynder
Din løsning...
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.