bmwmpower
05-07-2003, 12:46 PM
my problem in the display folder i have Duplicate in disply the folder why i don't know
i have 3 Function
1- Function for disply folder
2- Function for disply files
2- Function for sorting
ShowFolderList(server.mappath(d))
ShowFileList(server.mappath(d))
===========================
Function ShowFolderList(folderspec)
dim fso,f,sf,f1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 in sf
'====================================================
s = s & "<tr>"
s = s & "<td class='dataTD' width='5%' align='center' height='20'><a href='directory.asp?d=" & d + "\" + f1.name & "&c=" & c & "'><img src='imgs\folder.gif'alt='Open' border='0'></a></td>"
s = s & "<td class='dataTD' width='160' align='Left' height='20'><b><font size='1' face='Verdana'>" & f1.name & "</font></b></td>"
s = s & "<td class='dataTD' width='80' align='center' height='10'><b><font size='1' face='Verdana'>" &f1.size& "</font></b></td>"
s = s & "<td class='dataTD' width='140' align='center' height='10'><b><font size='1' face='Verdana'>" & f1.datecreated & "</font></b></td>"
s = s & "</tr>"
's = s & "<br>"
s = replace(s,"\\","\")
Next
response.write s
End Function
==============================================
Function ShowFileList(sMapPath)
Dim sSort
Dim FileArray() ' (0 is name, 1 is size, and 2 is last modified)
Dim objFSO
Dim objFile
Dim objFolder
'Dim sMapPath
Dim sUrlPath
Dim filename, filecollection, filesize, modified
Dim i
Dim FinalFileArray
'sMapPath = Server.MapPath(sUrlPath)
' Create FSO object and buddies
Set objFSO = createobject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(sMapPath)
Set filecollection = objFolder.Files
' Resize file array to appropriate numbe
' r of files to hold (with 3 attributes to
' hold
Redim FileArray(2,filecollection.count - 1)
Redim FinalFileArray(2,filecollection.count - 1)
' Load file data into array
i = 0
For Each objFile In objFolder.Files
filename=right(objFile.name,len(objFile.name)-InStrRev(objFile.name, "\"))
filesize = objFile.size
modified = objFile.datecreated
FileArray(0, i) = filename
FileArray(1, i) = filesize
FileArray(2, i) = modified
i = i + 1
Next
' Sort array according to method
'sSort = Request("Sort")
sSort ="Modified"
Select Case sSort
Case "Name"
FinalFileArray = SortAlpha(FileArray,"DESC",0)
Case "Size"
FinalFileArray = SortAlpha(FileArray,"DESC",1)
Case "Modified"
FinalFileArray = SortAlpha(FileArray,"DESC",2)
End Select
'==========================================================
For i = 0 To Ubound(FinalFileArray,2)
filename=FinalFileArray(0,i)
filesize = FinalFileArray(1,i)
modified = FinalFileArray(2,i)
'=====================================================
s = s & "<tr>"
s = s & "<td class='dataTD' width='5%' height='15' align='center'><b><font face='Verdana' size='1'><a href='" & d & "\" & filename & "' target='_Blank'><img src='" & img & "'alt='View File' border='0'></a></font></b></td>"
's = s & "<td width='65%' height='20' align='center'><b><font face='Verdana' size='1'><a href='read.asp?d=" & d & "&f=" & filename & "' target='_blank'>" & lcase(filename) & "</a>"
s = s & "<td class='dataTD' width='160' height='15' align='left'><b><font face='Verdana' size='2'>" & filename & "</font></b></td>"
s = s & "<td class='dataTD' width='80' align='center' height='10'><b><font size='1' face='Verdana'>" &filesize& "</font></b></td>"
s = s & "<td class='dataTD' width='140' align='center' height='15'><b><font size='1' face='Verdana'>" & modified & "</font></b></td>"
s = s & "</tr>"
s = replace(s,"\\","\")
end if
Next
Response.Write s
End Function
==============================================
Function SortAlpha(ary, direction, indexnum)
Dim StopWork
Dim i
Dim i2
Dim firstval()
Dim secondval()
redim firstval(ubound(ary,1))
redim secondval(ubound(ary,1))
StopWork=False
Do Until StopWork=True
StopWork=True
For i = 0 To UBound(ary,2)
if i=UBound(ary,2) Then Exit For
if UCase(Direction) = "DESC" Then
if ary(indexnum,i) < ary(indexnum,i+1) Then
For i2 = 0 To ubound(firstval)
firstval(i2) = ary(i2,i)
secondval(i2) = ary(i2,i+1)
ary(i2,i) = secondval(i2)
ary(i2,i+1) = firstval(i2)
Next
StopWork=False
End if
Else
if ary(indexnum,i) > ary(indexnum,i+1) Then
For i2 = 0 To ubound(firstval)
firstval(i2) = ary(i2,i)
secondval(i2) = ary(i2,i+1)
ary(i2,i) = secondval(i2)
ary(i2, i+1) = firstval(i2)
Next
StopWork=False
End if
End if
Next
Loop
SortAlpha=ary
End function
i have 3 Function
1- Function for disply folder
2- Function for disply files
2- Function for sorting
ShowFolderList(server.mappath(d))
ShowFileList(server.mappath(d))
===========================
Function ShowFolderList(folderspec)
dim fso,f,sf,f1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 in sf
'====================================================
s = s & "<tr>"
s = s & "<td class='dataTD' width='5%' align='center' height='20'><a href='directory.asp?d=" & d + "\" + f1.name & "&c=" & c & "'><img src='imgs\folder.gif'alt='Open' border='0'></a></td>"
s = s & "<td class='dataTD' width='160' align='Left' height='20'><b><font size='1' face='Verdana'>" & f1.name & "</font></b></td>"
s = s & "<td class='dataTD' width='80' align='center' height='10'><b><font size='1' face='Verdana'>" &f1.size& "</font></b></td>"
s = s & "<td class='dataTD' width='140' align='center' height='10'><b><font size='1' face='Verdana'>" & f1.datecreated & "</font></b></td>"
s = s & "</tr>"
's = s & "<br>"
s = replace(s,"\\","\")
Next
response.write s
End Function
==============================================
Function ShowFileList(sMapPath)
Dim sSort
Dim FileArray() ' (0 is name, 1 is size, and 2 is last modified)
Dim objFSO
Dim objFile
Dim objFolder
'Dim sMapPath
Dim sUrlPath
Dim filename, filecollection, filesize, modified
Dim i
Dim FinalFileArray
'sMapPath = Server.MapPath(sUrlPath)
' Create FSO object and buddies
Set objFSO = createobject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(sMapPath)
Set filecollection = objFolder.Files
' Resize file array to appropriate numbe
' r of files to hold (with 3 attributes to
' hold
Redim FileArray(2,filecollection.count - 1)
Redim FinalFileArray(2,filecollection.count - 1)
' Load file data into array
i = 0
For Each objFile In objFolder.Files
filename=right(objFile.name,len(objFile.name)-InStrRev(objFile.name, "\"))
filesize = objFile.size
modified = objFile.datecreated
FileArray(0, i) = filename
FileArray(1, i) = filesize
FileArray(2, i) = modified
i = i + 1
Next
' Sort array according to method
'sSort = Request("Sort")
sSort ="Modified"
Select Case sSort
Case "Name"
FinalFileArray = SortAlpha(FileArray,"DESC",0)
Case "Size"
FinalFileArray = SortAlpha(FileArray,"DESC",1)
Case "Modified"
FinalFileArray = SortAlpha(FileArray,"DESC",2)
End Select
'==========================================================
For i = 0 To Ubound(FinalFileArray,2)
filename=FinalFileArray(0,i)
filesize = FinalFileArray(1,i)
modified = FinalFileArray(2,i)
'=====================================================
s = s & "<tr>"
s = s & "<td class='dataTD' width='5%' height='15' align='center'><b><font face='Verdana' size='1'><a href='" & d & "\" & filename & "' target='_Blank'><img src='" & img & "'alt='View File' border='0'></a></font></b></td>"
's = s & "<td width='65%' height='20' align='center'><b><font face='Verdana' size='1'><a href='read.asp?d=" & d & "&f=" & filename & "' target='_blank'>" & lcase(filename) & "</a>"
s = s & "<td class='dataTD' width='160' height='15' align='left'><b><font face='Verdana' size='2'>" & filename & "</font></b></td>"
s = s & "<td class='dataTD' width='80' align='center' height='10'><b><font size='1' face='Verdana'>" &filesize& "</font></b></td>"
s = s & "<td class='dataTD' width='140' align='center' height='15'><b><font size='1' face='Verdana'>" & modified & "</font></b></td>"
s = s & "</tr>"
s = replace(s,"\\","\")
end if
Next
Response.Write s
End Function
==============================================
Function SortAlpha(ary, direction, indexnum)
Dim StopWork
Dim i
Dim i2
Dim firstval()
Dim secondval()
redim firstval(ubound(ary,1))
redim secondval(ubound(ary,1))
StopWork=False
Do Until StopWork=True
StopWork=True
For i = 0 To UBound(ary,2)
if i=UBound(ary,2) Then Exit For
if UCase(Direction) = "DESC" Then
if ary(indexnum,i) < ary(indexnum,i+1) Then
For i2 = 0 To ubound(firstval)
firstval(i2) = ary(i2,i)
secondval(i2) = ary(i2,i+1)
ary(i2,i) = secondval(i2)
ary(i2,i+1) = firstval(i2)
Next
StopWork=False
End if
Else
if ary(indexnum,i) > ary(indexnum,i+1) Then
For i2 = 0 To ubound(firstval)
firstval(i2) = ary(i2,i)
secondval(i2) = ary(i2,i+1)
ary(i2,i) = secondval(i2)
ary(i2, i+1) = firstval(i2)
Next
StopWork=False
End if
End if
Next
Loop
SortAlpha=ary
End function