Den här koden <code> Jag får Ok testa:Omvänd lista.
<code>
Dim objFSO, objFile
Dim sMapPath, objFolder
'Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("data/") ' this means the current directory
'Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
' Then for each file in the object we loop through and print the file and when it was last modified
For Each objFile in objFolder.Files
Response.Write "" ' Print out a link to the file
Response.write Left(objFile.Name, Len(objFile.Name) - 4) ' the file name and its date
Response.write "<br>" & vbCrlf ' close the tags
Next ' Loop back
' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
</code>
Skriver ut det här
2002-05-06
2003-05-07
2003-12-10
2004-01-23
Nu vill jag ha det omvänt, så att det blir
2004-01-23
2003-12-10
2003-05-07
2002-05-06
Hur gör jag?
Tack på förhand :)Sv: Omvänd lista.
Dim objFSO, objFile
Dim sMapPath, objFolder
Dim Links(0)
'Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("data/") ' this means the current directory
'Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
' Then for each file in the object we loop through and print the file and when it was last modified
For Each objFile in objFolder.Files
x = UBound(Links) +1
ReDim Preserve Links(x)
Links(x) = "" ' Print out a link to the file
Links(x) = Links(x) & Left(objFile.Name, Len(objFile.Name) - 4) ' the file name and its date
Links(x) = Links(x) & " <br>" ' close the tags
Next ' Loop back
For i = UBound(Links) To 1 Step -1
Response.Write Links(i)
Next 'i
' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
</code>
Har inte testat koden själv, men den borde fungera...
ThomasSv: Omvänd lista.
Microsoft VBScript runtime error '800a000a'
This array is fixed or temporarily locked
/diary/index.asp, line 71 Sv: Omvänd lista.
<code>
Dim objFSO, objFile
Dim sMapPath, objFolder
Dim Links()
'Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("data/") ' this means the current directory
'Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
' Then for each file in the object we loop through and print the file and when it was last modified
ReDim Links(0)
For Each objFile in objFolder.Files
x = UBound(Links) +1
ReDim Preserve Links(x)
Links(x) = "" ' Print out a link to the file
Links(x) = Links(x) & Left(objFile.Name, Len(objFile.Name) - 4) ' the file name and its date
Links(x) = Links(x) & " <br>" ' close the tags
Next ' Loop back
For i = UBound(Links) To 1 Step -1
Response.Write Links(i)
Next 'i
' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
</code>