L
Lukelrc
Hi,
I have some VBscript that lists the files in a folder. What i want to
do is populate an array with the file names and then use that array to
populate a list box. I have got as far as populating the array, but i
can't get rid of the error 'Subscript Out Of Range' Can anyone see
where i have gone wrong?
<script language = vbscript runat=Server>
Dim VFileItem
Dim vFiles
Dim objFileSysOb
Dim colFolderName
Dim Count
Count = 0
Dim ListOfFiles()
vSFolder = Session("availablepath")
Set objFileSysOb = Server.CreateObject("Scripting.FileSystemObject")
Set colFolderName = objFileSysOb.GetFolder(vSFolder)
Set vFiles =colFolderName.Files
Response.Write "<b>The Files in the folder are:</b><p>"
For each vFileItem in vFiles
ListofFiles(Count) = vFileItem
Count = Count + 1
Next
for i = 0 to Count
document.write(ListOfFiles(i) & "<br />")
next
</script>
I have some VBscript that lists the files in a folder. What i want to
do is populate an array with the file names and then use that array to
populate a list box. I have got as far as populating the array, but i
can't get rid of the error 'Subscript Out Of Range' Can anyone see
where i have gone wrong?
<script language = vbscript runat=Server>
Dim VFileItem
Dim vFiles
Dim objFileSysOb
Dim colFolderName
Dim Count
Count = 0
Dim ListOfFiles()
vSFolder = Session("availablepath")
Set objFileSysOb = Server.CreateObject("Scripting.FileSystemObject")
Set colFolderName = objFileSysOb.GetFolder(vSFolder)
Set vFiles =colFolderName.Files
Response.Write "<b>The Files in the folder are:</b><p>"
For each vFileItem in vFiles
ListofFiles(Count) = vFileItem
Count = Count + 1
Next
for i = 0 to Count
document.write(ListOfFiles(i) & "<br />")
next
</script>