---
title: "Denna kod?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/74184-denna-kod"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "oGGo"
published: "2003-04-15T18:29:00.000Z"
updated: "2003-04-15T21:35:17.000Z"
replies: 11
views: 328
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/74184-denna-kod"
---

# Denna kod?

## #1 — oGGo, 2003-04-15T18:29Z

Hej, jag har eftersökt ett ASP script som listar filer i bokstavsordning nu i X antal månader, efter en felsökning hittade jag dock det.
Nu är det dock så att den inte visar mappar när den listar en mapp, utan bara filerna i mappen.
Dessutom undrar jag om det e möjligt att browsra mapparna som listas direkt på sidan ex. listfiles.asp?browse=txt/a/apa/

om ni nu förstår vad jag menar.

\<%@ language = VBScript %\>

\<% 
  Option Explicit
  On Error Resume Next
  Response.buffer = true

  DIM objFSO, objFolder, objFilesInFolder
  DIM arrFiles(), mFileCount, mPageSize, mPageNo, mPageCount
  DIM mDirPath, mFileSpec, mFile, mTemp
  DIM mServerName
  DIM i, j, k, s0, s1
  DIM mformPage, mformCtl, mformCtlVal
  Dim mDownloadDir, mHttpPath

  ' Change as appropriate to your needs
  mPageSize = 999

  ' Change to the actual directory name you have
  mDownloadDir = " "

  ' mDownloadDir should be one subdirectory down from where this page resides, e.g.
  ' if this page is on C:\\InetPub\\Wwwroot, your dir is C:\\InetPub\\Wwwroot\\Downloads.
  ' The page should of course be in a directory that is defined as the home
  ' or a virtual directory.  
  

  mDirPath = server.mapPath(".") & "\\" & mDownloadDir

  '-----------------------------------------------
  ' Following the earlier remarks, if C:\\Inetpub\\wwwroot is home directory,
  'and this page is in C:\\InetPub\\Wwwroot, the URL should be
  '-----------------------------------------------
  mHttpPath = mDownloadDir & "/webs/ackord2/"

  '-----------------------------------------------
  ' but if this page is not in the home or a virtual directory
    '(e.g,. on PWS, the page may be in C:\\InetPub\\Webpub but C:\\Inetpub\\wwwroot is
    'defined as the home directory), then you need to adjust:
  '-----------------------------------------------
  ' mHttpPath = "/WebPub/" & mDownloadDir & "/"  

  ' Instances of object 
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFolder = objFSO.GetFolder(mDirPath)  
  Set objFilesInFolder = objFolder.Files
  mFileCount = objFilesInFolder.Count

  IF mFileCount = 0 Then 
  Response.write "Det finns inga ackord av denna artisten än."
  Set objFSO = Nothing
  Set objFolder = Nothing
  Set objFilesInFolder = Nothing
  Response.End 
  End If

  mPageCount = INT(mFileCount \\ mPageSize)
  IF ( mFileCount Mod mPageSize) \> 0 THEN
  mPageCount = mPageCount + 1
  End If

  ' Test the existence of a control on form. If exists, its name should
  ' have been wrapped up in HTTP header, since our form uses POST method.
  mformPage = Request.Form("HiddenPage")
  If mformPage \<\> "" Then 
  IF mPageCount \> 1 Then
  mPageNo = Cint(mformPage)
  ' Test the values returned. The unselected ones would have
  ' the pattern of "xxx" and the selected one "xxx, xxx".
  For Each mformCtl In Request.Form
  mformCtlVal = Request.Form(mformCtl)
  IF mformCtlVal = "First, First" Then
  mPageNo = 1
  Exit For 
  ElseIf mformCtlVal = "Previous, Previous" Then
  mPageNo = mPageNo - 1
  Exit For
  ElseIf mformCtlVal = "Next, Next" Then
  mPageNo = mPageNo + 1
  Exit For
  ElseIf mformCtlVal = "Last, Last" Then
  mPageNo = mPageCount
  Exit For
  End if
  Next
  Else  
  mPageNo = 1
  End If
  Else  ' First run
  mPageNo = 1
  End If

  ' Two dimension array, for File Name and Size columns (entry for Description
  ' column not provided here)
  ReDim arrFiles(mFileCount-1, 1)

  ' Store file name, size info to array 
  i = 0
  For Each mFile In objFilesInFolder 
  ' First char upper, rest lower case, for display purposes only
  mTemp=UCASE(LEFT(mFile.Name,1)) & LCASE((RIGHT(mFile.Name, LEN(mFile.Name) -1)))
  arrFiles(i, 0) = mTemp

  ' Fill file size
  arrFiles(i, 1) = mFile.Size
  i = i + 1
  Next

  ' Sort array by file name
  For i = 0 To UBOUND(arrFiles)-1
  k = i
  s0 = arrFiles(i, 0)
  s1 = arrFiles(i, 1)
  For j = i + 1 To UBound(arrFiles)
  If StrComp(arrFiles(j, 0), s0, vbTextCompare) \< 0 Then
  s0 = arrFiles(j, 0)
  s1 = arrFiles(j, 1)
  k = j
  End If
  Next 
  arrFiles(k, 0) = arrFiles(i, 0)
  arrFiles(k, 1) = arrFiles(i, 1)
  arrFiles(i, 0) = s0
  arrFiles(i, 1) = s1
  Next 
%\>

\<html\>
\<head\>
\<meta http-equiv="Content-Type"; Content="text/html; Charset=iso-8859-1"\>
\</head\>
\<body\>
\<%'\<IMAGE SRC="LisFiles.gif" VSPACE=2 HSPACE=15 ALIGN=LEFT\> %\>
  
\<b\>
\<font face="arial" size="4"\>Filer:\</font\>
\</b\>
\<font color="black" face="arial" size="4"\>\</font\>
\<br\>
\<br\>
\<font face="arial" size="1"\> \<b\> Totalt:\<%= cStr(mFileCount) %\> filer\</b\>\</font\>
\<br\>

\<table cellpadding=6 cellspacing=0 border=0 style="border-collapse: collapse" bordercolor="#111111"\>
  

\<% 
  k = (mPageNo - 1) \* mPageSize
  j = 0
  FOR i = k To mFileCount -1
  '-------------------------------------------------------------------
  ' To form an URL which will be used as an anchor tag for file name
  '-------------------------------------------------------------------
  
  mTemp = mHttpPath & arrFiles(i, 0)
%\>

  \<TR\>\<TD\>\<A HREF="\<%=mTemp%\>"\> \<%=arrFiles(i,0)%\> \</A\> \<BR\>\</TD\>

\<%  
  j = j + 1  ' Count to control the max 
  IF j = mPageSize then  ' j is zero-based
  Exit For
  End If
  Next

  ' Fill up one page with blanks
  DO WHILE j \< mPageSize
%\>
\<%
  j = j + 1
  LOOP
%\>
\</TABLE\>

\<FORM NAME="UpdPage" ACTION="LisFiles.asp" METHOD="POST"\>
\<INPUT TYPE="HIDDEN" NAME="HiddenPage" VALUE="\<%=cstr(mPageNo)%\>"\>
\<INPUT TYPE="HIDDEN" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"\> 
\<INPUT TYPE="HIDDEN" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"\>
\<INPUT TYPE="HIDDEN" NAME="OfNext"  VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"\>
\<INPUT TYPE="HIDDEN" NAME="OfLast"  VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"\>

\<% IF mPageCount\>1 Then %\>
\<% If mPageNo=1 Then %\>
\<INPUT TYPE="SUBMIT" NAME="OfNext"  VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"\>
\<% If mPageCount\>2 Then %\>
\<INPUT TYPE="SUBMIT" NAME="OfLast"  VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"\>
\<% End If %\>
\<% ElseIf mPageNo=mPageCount Then %\>
\<% If mPageCount\>2 Then %\>
\<INPUT TYPE="SUBMIT" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"\> 
\<% End If %\>
\<INPUT TYPE="SUBMIT" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"\>
\<% ElseIf mPageNo\>1 And mPageNo\<mPageCount Then %\>
\<% If mPageCount\>2 Then %\>
\<INPUT TYPE="SUBMIT" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"\> 
\<% End If %\>
\<INPUT TYPE="SUBMIT" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"\>
\<INPUT TYPE="SUBMIT" NAME="OfNext"  VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"\>
\<% If mPageCount\>2 Then %\>
\<INPUT TYPE="SUBMIT" NAME="OfLast"  VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"\>
\<% End If %\>
\<% End If %\>
\<% End If %\>

\</FORM\>
\</BODY\>
\</HTML\>
\<%
  Set objFSO = Nothing
  Set objFolder = Nothing
  Set objFilesInFolder = Nothing
  Response.End
%\>

Detta är koden jag hittade!!!

Snälla hjälp, ni anar inte hur glad jag skulle bli :)

Permalänk: https://www.webforum.nu/p/74184

## #2 — Jesper T, 2003-04-15T18:49Z

Testa med att lägga till detta innan du loopar filerna:

```
For each Item in objFolder.SubFolders
Response.write Item.Name
next
```

Permalänk: https://www.webforum.nu/p/1014431

## #3 — oGGo, 2003-04-15T18:54Z

Det händer inte ett jota...
Om du menade att jag skulle plocka in dom såhär:

\<%
For each Item in objFolder.SubFolders
Response.write Item.Name
next
        j = j + 1
   LOOP
%\>

Permalänk: https://www.webforum.nu/p/1014438

## #4 — oGGo, 2003-04-15T19:00Z

Men det viktigaste är nog ändå att man skall kunna browsra genom att få sidan att bli såhär:

listfiles.asp?browse=txt/w/ ...osv

näää förresten :) ... båda är lika viktiga :)

Permalänk: https://www.webforum.nu/p/1014444

## #5 — oGGo, 2003-04-15T19:01Z

om någon har ett annat script som listar alla filer + mappar i bokstavsordning (viktigt) så skulle det också vara nice förstås !!!

Permalänk: https://www.webforum.nu/p/1014446

## #6 — solbulle, 2003-04-15T19:23Z

Du kan starta med att radera: "On Error Resume Next" med den raden kvar lär du få svårt att fixa till ditt script.

Testa detta, det ger dig mappnamnen:

```
<%@ language = VBScript %> 

<% 
Option Explicit 
'On Error Resume Next 
Response.buffer = true 

DIM objFSO, objFolder, objFilesInFolder 
DIM arrFiles(), mFileCount, mPageSize, mPageNo, mPageCount 
DIM mDirPath, mFileSpec, mFile, mTemp 
DIM mServerName 
DIM i, j, k, s0, s1 
DIM mformPage, mformCtl, mformCtlVal 
Dim mDownloadDir, mHttpPath, SubFolders, item 

' Change as appropriate to your needs 
mPageSize = 999 

' Change to the actual directory name you have 
mDownloadDir = " " 

' mDownloadDir should be one subdirectory down from where this page resides, e.g. 
' if this page is on C:\InetPub\Wwwroot, your dir is C:\InetPub\Wwwroot\Downloads. 
' The page should of course be in a directory that is defined as the home 
' or a virtual directory. 

mDirPath = server.mapPath(".") & "\" & mDownloadDir 

'----------------------------------------------- 
' Following the earlier remarks, if C:\Inetpub\wwwroot is home directory, 
'and this page is in C:\InetPub\Wwwroot, the URL should be 
'----------------------------------------------- 
mHttpPath = mDownloadDir & "/webs/ackord2/" 

'----------------------------------------------- 
' but if this page is not in the home or a virtual directory 
'(e.g,. on PWS, the page may be in C:\InetPub\Webpub but C:\Inetpub\wwwroot is 
'defined as the home directory), then you need to adjust: 
'----------------------------------------------- 
' mHttpPath = "/WebPub/" & mDownloadDir & "/" 

' Instances of object 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFSO.GetFolder(mDirPath) 
Set objFilesInFolder = objFolder.Files 
mFileCount = objFilesInFolder.Count 

Set subFolders = objFolder.SubFolders

IF mFileCount = 0 Then 
Response.write "Det finns inga ackord av denna artisten än." 
Set objFSO = Nothing 
Set objFolder = Nothing 
Set objFilesInFolder = Nothing 
Response.End 
End If 

mPageCount = INT(mFileCount \ mPageSize) 
IF ( mFileCount Mod mPageSize) > 0 THEN 
mPageCount = mPageCount + 1 
End If 

' Test the existence of a control on form. If exists, its name should 
' have been wrapped up in HTTP header, since our form uses POST method. 
mformPage = Request.Form("HiddenPage") 
If mformPage <> "" Then 
IF mPageCount > 1 Then 
mPageNo = Cint(mformPage) 
' Test the values returned. The unselected ones would have 
' the pattern of "xxx" and the selected one "xxx, xxx". 
For Each mformCtl In Request.Form 
mformCtlVal = Request.Form(mformCtl) 
IF mformCtlVal = "First, First" Then 
mPageNo = 1 
Exit For 
ElseIf mformCtlVal = "Previous, Previous" Then 
mPageNo = mPageNo - 1 
Exit For 
ElseIf mformCtlVal = "Next, Next" Then 
mPageNo = mPageNo + 1 
Exit For 
ElseIf mformCtlVal = "Last, Last" Then 
mPageNo = mPageCount 
Exit For 
End if 
Next 
Else 
mPageNo = 1 
End If 
Else ' First run 
mPageNo = 1 
End If 

' Two dimension array, for File Name and Size columns (entry for Description 
' column not provided here) 
ReDim arrFiles(mFileCount-1, 1) 

' Store file name, size info to array 
i = 0

For each Item in SubFolders
Response.write Item.Name & "<BR>"
next

For Each mFile In objFilesInFolder 
' First char upper, rest lower case, for display purposes only 
mTemp=UCASE(LEFT(mFile.Name,1)) & LCASE((RIGHT(mFile.Name, LEN(mFile.Name) -1))) 
arrFiles(i, 0) = mTemp 

' Fill file size 
arrFiles(i, 1) = mFile.Size 
i = i + 1 
Next 

' Sort array by file name 
For i = 0 To UBOUND(arrFiles)-1 
k = i 
s0 = arrFiles(i, 0) 
s1 = arrFiles(i, 1) 
For j = i + 1 To UBound(arrFiles) 
If StrComp(arrFiles(j, 0), s0, vbTextCompare) < 0 Then 
s0 = arrFiles(j, 0) 
s1 = arrFiles(j, 1) 
k = j 
End If 
Next 
arrFiles(k, 0) = arrFiles(i, 0) 
arrFiles(k, 1) = arrFiles(i, 1) 
arrFiles(i, 0) = s0 
arrFiles(i, 1) = s1 
Next 
%> 

<html> 
<head> 
<meta http-equiv="Content-Type"; Content="text/html; Charset=iso-8859-1"> 
</head> 
<body> 
<%'<IMAGE SRC="LisFiles.gif" VSPACE=2 HSPACE=15 ALIGN=LEFT> %> 

<b> 
<font face="arial" size="4">Filer:</font> 
</b> 
<font color="black" face="arial" size="4"></font> 
<br> 
<br> 
<font face="arial" size="1"> <b> Totalt:<%= cStr(mFileCount) %> filer</b></font> 
<br> 

<table cellpadding=6 cellspacing=0 border=0 style="border-collapse: collapse" bordercolor="#111111"> 

<% 
k = (mPageNo - 1) * mPageSize 
j = 0 
FOR i = k To mFileCount -1 
'------------------------------------------------------------------- 
' To form an URL which will be used as an anchor tag for file name 
'------------------------------------------------------------------- 

mTemp = mHttpPath & arrFiles(i, 0) 
%> 

<TR><TD><A HREF="<%=mTemp%>"> <%=arrFiles(i,0)%> </A> <BR></TD> 

<% 
j = j + 1 ' Count to control the max 
IF j = mPageSize then ' j is zero-based 
Exit For 
End If 
Next 

' Fill up one page with blanks 
DO WHILE j < mPageSize 

j = j + 1 
LOOP 
%> 
</TABLE> 

<FORM NAME="UpdPage" ACTION="LisFiles.asp" METHOD="POST"> 
<INPUT TYPE="HIDDEN" NAME="HiddenPage" VALUE="<%=cstr(mPageNo)%>"> 
<INPUT TYPE="HIDDEN" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<INPUT TYPE="HIDDEN" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<INPUT TYPE="HIDDEN" NAME="OfNext" VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<INPUT TYPE="HIDDEN" NAME="OfLast" VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 

<% IF mPageCount>1 Then %> 
<% If mPageNo=1 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfNext" VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% If mPageCount>2 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfLast" VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% End If %> 
<% ElseIf mPageNo=mPageCount Then %> 
<% If mPageCount>2 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% End If %> 
<INPUT TYPE="SUBMIT" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% ElseIf mPageNo>1 And mPageNo<mPageCount Then %> 
<% If mPageCount>2 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% End If %> 
<INPUT TYPE="SUBMIT" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<INPUT TYPE="SUBMIT" NAME="OfNext" VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% If mPageCount>2 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfLast" VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% End If %> 
<% End If %> 
<% End If %> 

</FORM> 
</BODY> 
</HTML> 
<% 
Set objFSO = Nothing 
Set objFolder = Nothing 
Set objFilesInFolder = Nothing 
Response.End 
%>
```

Permalänk: https://www.webforum.nu/p/1014463

## #7 — oGGo, 2003-04-15T19:46Z

tack så mycket...bara dock en grej...mapparna vart inte listade i bokstavsordning :)

Kan man inte istället bryta ut från denna kod, det som gör att allt blir i bokstavsordning och slänga in det i en annan kod som är lite kortare och mindre komplicerad & där funktionen sidan.asp?browse=w/wreeswijk cornelis/ också finns ?????

Permalänk: https://www.webforum.nu/p/1014482

## #8 — oGGo, 2003-04-15T19:46Z

alltså, ni anar inte hur glad jag skulle bli om det funkade till slut !!!

Permalänk: https://www.webforum.nu/p/1014484

## #9 — oGGo, 2003-04-15T19:50Z

Den här vet jag funkar bra...

\<%
strUser = ""

Dim strFolder, Whichfolder, strParent

strFolder = Request.Querystring("folder")

If Len(strFolder) = 0 Then
strParent = ""
ElseIf Len(strFolder) = 1 Then
strParent = ""
Else
intPos = InStrRev(strFolder, "\\")-1
If intPos = 0 Then
strParent = ""
Else
strParent = Left(strFolder, intPos)
End If
End If

Whichfolder = Server.MapPath("\\") & strFolder & "\\"

Dim fs, f, f1, fc
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(Whichfolder)
Set fc = f.subfolders

For Each f1 in fc
   Response.write "\<A href='default.asp?folder=" & strFolder & "\\" & f1.name & "'\>" & f1.name & "\</A\>\<BR\>"
Next

'----------------------------------V€LJ FIL----------------------------------

Set fc = f.files

For Each f1 in fc
   Response.write "\<A href='" & Replace(strFolder & "\\", "\\", "/") & f1.name & "'\>" & f1.name & "\</A\>\<BR\>"
Next

Set fc = nothing
Set f = nothing
Set fs = nothing
%\>

Permalänk: https://www.webforum.nu/p/1014489

## #10 — solbulle, 2003-04-15T20:37Z

Kanske en bit på väg... Iofs är ju det bästa, precis som du skriver, att göra en funktion av det hela.

```
<%@ language = VBScript %> 

<% 
Option Explicit 
'On Error Resume Next 
Response.buffer = true 

DIM objFSO, objFolder, objFilesInFolder 
DIM arrFiles(), mFileCount, mPageSize, mPageNo, mPageCount 
DIM mDirPath, mFileSpec, mFile, mTemp 
DIM mServerName 
DIM i, j, k, s0, s1 
DIM mformPage, mformCtl, mformCtlVal 
Dim mDownloadDir, mHttpPath, SubFolders, item, arrFilesf, mFolderCount

' Change as appropriate to your needs 
mPageSize = 999 

' Change to the actual directory name you have 
mDownloadDir = " " 

' mDownloadDir should be one subdirectory down from where this page resides, e.g. 
' if this page is on C:\InetPub\Wwwroot, your dir is C:\InetPub\Wwwroot\Downloads. 
' The page should of course be in a directory that is defined as the home 
' or a virtual directory. 

mDirPath = server.mapPath(".") & "\" & mDownloadDir 

'----------------------------------------------- 
' Following the earlier remarks, if C:\Inetpub\wwwroot is home directory, 
'and this page is in C:\InetPub\Wwwroot, the URL should be 
'----------------------------------------------- 
mHttpPath = mDownloadDir & "/webs/ackord2/" 

'----------------------------------------------- 
' but if this page is not in the home or a virtual directory 
'(e.g,. on PWS, the page may be in C:\InetPub\Webpub but C:\Inetpub\wwwroot is 
'defined as the home directory), then you need to adjust: 
'----------------------------------------------- 
' mHttpPath = "/WebPub/" & mDownloadDir & "/" 

' Instances of object 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFSO.GetFolder(mDirPath) 
Set objFilesInFolder = objFolder.Files 
mFileCount = objFilesInFolder.Count 

Set subFolders = objFolder.SubFolders
mFolderCount = subFolders.Count

IF mFileCount = 0 Then 
Response.write "Det finns inga ackord av denna artisten än." 
Set objFSO = Nothing 
Set objFolder = Nothing 
Set objFilesInFolder = Nothing 
Response.End 
End If 

mPageCount = INT(mFileCount \ mPageSize) 
IF ( mFileCount Mod mPageSize) > 0 THEN 
mPageCount = mPageCount + 1 
End If 

' Test the existence of a control on form. If exists, its name should 
' have been wrapped up in HTTP header, since our form uses POST method. 
mformPage = Request.Form("HiddenPage") 
If mformPage <> "" Then 
IF mPageCount > 1 Then 
mPageNo = Cint(mformPage) 
' Test the values returned. The unselected ones would have 
' the pattern of "xxx" and the selected one "xxx, xxx". 
For Each mformCtl In Request.Form 
mformCtlVal = Request.Form(mformCtl) 
IF mformCtlVal = "First, First" Then 
mPageNo = 1 
Exit For 
ElseIf mformCtlVal = "Previous, Previous" Then 
mPageNo = mPageNo - 1 
Exit For 
ElseIf mformCtlVal = "Next, Next" Then 
mPageNo = mPageNo + 1 
Exit For 
ElseIf mformCtlVal = "Last, Last" Then 
mPageNo = mPageCount 
Exit For 
End if 
Next 
Else 
mPageNo = 1 
End If 
Else ' First run 
mPageNo = 1 
End If 

'### MAPPAR

' Store file name, size info to array 
i = 0

' Two dimension array, for File Name and Size columns (entry for Description 
' column not provided here) 
ReDim arrFilesf(mFolderCount-1, 1) 

For each Item in SubFolders
' First char upper, rest lower case, for display purposes only 
mTemp=UCASE(LEFT(Item.Name,1)) & LCASE((RIGHT(Item.Name, LEN(Item.Name) -1))) 
arrFilesf(i, 0) = mTemp 

' Fill file size 
arrFilesf(i, 1) = Item.Size 
i = i + 1 
Next 

' Sort array by file name 
For i = 0 To UBOUND(arrFilesf)-1 
k = i 
s0 = arrFilesf(i, 0) 
s1 = arrFilesf(i, 1) 
For j = i + 1 To UBound(arrFilesf) 
If StrComp(arrFilesf(j, 0), s0, vbTextCompare) < 0 Then 
s0 = arrFilesf(j, 0) 
s1 = arrFilesf(j, 1) 
k = j 
End If 
Next 
arrFilesf(k, 0) = arrFilesf(i, 0) 
arrFilesf(k, 1) = arrFilesf(i, 1) 
arrFilesf(i, 0) = s0 
arrFilesf(i, 1) = s1 
Next 

'### FILER

' Store file name, size info to array 
i = 0

' Two dimension array, for File Name and Size columns (entry for Description 
' column not provided here) 
ReDim arrFiles(mFileCount-1, 1) 

For Each mFile In objFilesInFolder 
' First char upper, rest lower case, for display purposes only 
mTemp=UCASE(LEFT(mFile.Name,1)) & LCASE((RIGHT(mFile.Name, LEN(mFile.Name) -1))) 
arrFiles(i, 0) = mTemp 

' Fill file size 
arrFiles(i, 1) = mFile.Size 
i = i + 1 
Next 

' Sort array by file name 
For i = 0 To UBOUND(arrFiles)-1 
k = i 
s0 = arrFiles(i, 0) 
s1 = arrFiles(i, 1) 
For j = i + 1 To UBound(arrFiles) 
If StrComp(arrFiles(j, 0), s0, vbTextCompare) < 0 Then 
s0 = arrFiles(j, 0) 
s1 = arrFiles(j, 1) 
k = j 
End If 
Next 
arrFiles(k, 0) = arrFiles(i, 0) 
arrFiles(k, 1) = arrFiles(i, 1) 
arrFiles(i, 0) = s0 
arrFiles(i, 1) = s1 
Next 
%> 

<html> 
<head> 
<meta http-equiv="Content-Type"; Content="text/html; Charset=iso-8859-1"> 
</head> 
<body> 
<%'<IMAGE SRC="LisFiles.gif" VSPACE=2 HSPACE=15 ALIGN=LEFT> %> 

<b> 
<font face="arial" size="4">Filer:</font> 
</b> 
<font color="black" face="arial" size="4"></font> 
<br> 
<br>

<font face="arial" size="1"> <b> Totalt:<%= cStr(mFolderCount) %> mappar</b></font> 
<br> 

<table cellpadding=6 cellspacing=0 border=0 style="border-collapse: collapse" bordercolor="#111111"> 

<% 
k = (mPageNo - 1) * mPageSize 
j = 0 
FOR i = k To mFolderCount -1 
'------------------------------------------------------------------- 
' To form an URL which will be used as an anchor tag for file name 
'------------------------------------------------------------------- 

mTemp = mHttpPath & arrFilesf(i, 0) 
%> 

<TR><TD><A HREF="<%=mTemp%>"> <%=arrFilesf(i,0)%> </A> <BR></TD> 

<% 
j = j + 1 ' Count to control the max 
IF j = mPageSize then ' j is zero-based 
Exit For 
End If 
Next 

' Fill up one page with blanks 
DO WHILE j < mPageSize 

j = j + 1 
LOOP 
%> 
</TABLE>

<font face="arial" size="1"> <b> Totalt:<%= cStr(mFileCount) %> filer</b></font> 
<br> 

<table cellpadding=6 cellspacing=0 border=0 style="border-collapse: collapse" bordercolor="#111111"> 

<% 
k = (mPageNo - 1) * mPageSize 
j = 0 
FOR i = k To mFileCount -1 
'------------------------------------------------------------------- 
' To form an URL which will be used as an anchor tag for file name 
'------------------------------------------------------------------- 

mTemp = mHttpPath & arrFiles(i, 0) 
%> 

<TR><TD><A HREF="<%=mTemp%>"> <%=arrFiles(i,0)%> </A> <BR></TD> 

<% 
j = j + 1 ' Count to control the max 
IF j = mPageSize then ' j is zero-based 
Exit For 
End If 
Next 

' Fill up one page with blanks 
DO WHILE j < mPageSize 

j = j + 1 
LOOP 
%> 
</TABLE> 

<FORM NAME="UpdPage" ACTION="LisFiles.asp" METHOD="POST"> 
<INPUT TYPE="HIDDEN" NAME="HiddenPage" VALUE="<%=cstr(mPageNo)%>"> 
<INPUT TYPE="HIDDEN" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<INPUT TYPE="HIDDEN" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<INPUT TYPE="HIDDEN" NAME="OfNext" VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<INPUT TYPE="HIDDEN" NAME="OfLast" VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 

<% IF mPageCount>1 Then %> 
<% If mPageNo=1 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfNext" VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% If mPageCount>2 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfLast" VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% End If %> 
<% ElseIf mPageNo=mPageCount Then %> 
<% If mPageCount>2 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% End If %> 
<INPUT TYPE="SUBMIT" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% ElseIf mPageNo>1 And mPageNo<mPageCount Then %> 
<% If mPageCount>2 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfFirst" VALUE="First" STYLE="POSITION: RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% End If %> 
<INPUT TYPE="SUBMIT" NAME="OfPrevious" VALUE="Previous" STYLE="POSITION:RELATIVE;LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<INPUT TYPE="SUBMIT" NAME="OfNext" VALUE="Next" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% If mPageCount>2 Then %> 
<INPUT TYPE="SUBMIT" NAME="OfLast" VALUE="Last" STYLE="POSITION:RELATIVE; LEFT=10; WIDTH=70; COLOR=MAROON;"> 
<% End If %> 
<% End If %> 
<% End If %> 

</FORM> 
</BODY> 
</HTML> 
<% 
Set objFSO = Nothing 
Set objFolder = Nothing 
Set objFilesInFolder = Nothing 
Response.End 
%>
```

Permalänk: https://www.webforum.nu/p/1014518

## #11 — oGGo, 2003-04-15T20:58Z

nice nice...nu till frågan om det går med någon enkel funktion att få in så man browsrar på sidan?

annars blir det lite jobbigt att sitta och trycka in en av varje av dessa sidor i varje mapp (400 st) på servern + att gå in i koden och fixa till vilken mapp filen ligger i

Permalänk: https://www.webforum.nu/p/1014527

## #12 — solbulle, 2003-04-15T21:35Z

Testa sökfunktionen, det du efterfrågar har varit upp relativt nyligen. Eller/och börja knåpa. Du har ju alla namn på mappar och filer, lägg dom i en querystring som du sen tar ner och använder i "funktionen" som listar filerna.

Permalänk: https://www.webforum.nu/p/1014540

---

Tråden på webben: https://www.webforum.nu/amne/asp/74184-denna-kod
