1. 其实我现在使用的就是一个比较完整的。代码见下:
2. 由于需要在两天之内写出来(the whole site),代码很不漂亮,也没有 err handle, optimize.
3. filesystemobject 只能用绝对路径。所以需要 mappath method.
4. Microsoft suminfo object 只支持本地文件,不能 net use...
5. 但是他有 c++ 的源代码,你可以...
6. 很抱歉没办法把整个站点和大家共享,因为在Intranet.
7. 为了对大家负责,我又看了一遍这段半年前的代码,好烂。 :-)
凑和用 8。 :-)
=================================
<%@ Language=VBScript %>
<%
' *********************************************************
'this file is written by
'kw copyright reserved. :-)
'if you have any question, directly contact w/ me.
'some features are just under construction...
' *********************************************************
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK REL="stylesheet" TYPE="text/css" HREF="/css/myCSS.CSS">
</HEAD>
<BODY>
<SCRIPT LANGUAGE=javascript>
<!--
function mousemove()
{
var srcElement;
srcElement=window.event.srcElement;
{
srcElement.className = "coolstyle";
}
}
function mouseout()
{
var srcElement;
srcElement=window.event.srcElement;
{
srcElement.className = "normalstyle";
}
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE=vbscript RUNAT = Server>
' Virtual Root
FileServerName = "fileserver"
VRoot = "/file"
' Get the files collection from current folder
dim fs, f, f1, fc, s
set fs = createobject("scripting.filesystemobject")
' begin of function - to get path info from external
' get Path parameter from external
sPath = Request("sPath")
if (sPath = "" or sPath = ".") then
sPath = "."
Response.Write "<TABLE class = tablefilename border=0 width='100%'>"
Response.Write "<TR align=center>"
sHelloString = "Hi, guy, i didn't get correct path info, so I can only show you current folder"
Response.Write "<TD>" & sHelloString & "</TD></TR></TABLE>"
end if
' merge Absolute path
sAbPath = server.MapPath (".") & "/" & sPath
set f = fs.GetFolder (sAbPath)
' end of function - to get path info from external
set fc = f.files
' Create suminfo object
dim suminfo
set SumInfo = Server.CreateObject("IISSample.SummaryInfo")
' Which kinds of document should be displayed?
'
bDocChecked = Request.Form ("doc")
bXDocChecked = Request("XDoc")
bPptChecked = Request.Form ("ppt")
bXPptChecked = Request("XPpt")
bXlsChecked = Request.Form ("xls")
bXXlsChecked = Request("XXls")
bTxtChecked = Request.Form ("txt")
bXTxtChecked = Request("XTxt")
bZipChecked = Request.Form ("zip")
bXZipChecked = Request("XZip")
' Display all document in the folder is dangerous, so...
'bAllChecked = Request.Form ("all")
' Tell the visitor how to display document
Response.Write "<TABLE class = tablefilename border=0 width='100%'>"
Response.Write "<TR align=center><TD>"
Response.Write "<font color=navy>"
Response.Write "Current folder: <a href='file://" &FileServerName & VRoot & "/" & sPath & "' target='_blank'>"
Response.Write "<span onmousemove='mousemove()' onmouseout='mouseout()'>"
Response.Write "//" & FileServerName & VRoot & "/" & sPath & "</a>"
Response.Write "</span>"
Response.Write "</font>"
Response.Write "</TD></TR>"
Response.Write "<TR align=center><TD>"
Response.Write "<font color=green>Please select the document type you want to list, and click Refresh</font>"
Response.Write "</TD></TR>"
Response.Write "<TR align=center><TD>"
Response.Write "<FORM action='display.asp" & "?sPath=" & sPath & "' id=choose_doc_type method=post name=FORM1>"
Response.Write "<INPUT id=checkbox1 name=doc type=checkbox "
if ( bDocChecked = "on" or bXDocChecked = "on" ) then Response.Write "checked"
Response.Write ">Word"
Response.Write "<INPUT id=checkbox2 name=ppt type=checkbox "
if ( bPptChecked = "on" or bXPptChecked = "on" ) then Response.Write "checked"
Response.Write ">Powerpoint"
Response.Write "<INPUT id=checkbox3 name=xls type=checkbox "
if ( bXlsChecked = "on" or bXXlsChecked = "on" ) then Response.Write "checked"
Response.Write ">Excel"
Response.Write "<INPUT id=checkbox4 name=txt type=checkbox "
if ( bTxtChecked = "on" or bXTxtChecked = "on" ) then Response.Write "checked"
Response.Write ">Text"
Response.Write "<INPUT id=checkbox5 name=zip type=checkbox "
if ( bZipChecked = "on" or bXZipChecked = "on" ) then Response.Write "checked"
Response.Write ">Zip"
' Display all document in the folder is dangerous, so...
'Response.Write "<INPUT id=checkbox6 name=all type=checkbox "
'if bAllChecked = "on" then Response.Write "checked"
'Response.Write ">All"
Response.Write "<INPUT id=submit1 name=submit1 type=submit value=Refresh>"
Response.Write "</FORM>"
Response.Write "</TD></TR>"
Response.Write "</TABLE>"
' list files & properties, one by one
' ===================================
' first above all, display table header
Response.Write "<TABLE border=0 width='100%'>"
for each f1 in fc
' get file name
s = f1.name
' get file type
filetype = right(s,3)
bDisplay = false
if filetype = "doc" and ( bDocChecked = "on" or bXDocChecked = "on" ) then bDisplay = true
if filetype = "ppt" and ( bPptChecked = "on" or bXPptChecked = "on" ) then bDisplay = true
if filetype = "xls" and ( bXlsChecked = "on" or bXXlsChecked = "on" ) then bDisplay = true
if filetype = "txt" and ( bTxtChecked = "on" or bXTxtChecked = "on" ) then bDisplay = true
if filetype = "zip" and ( bZipChecked = "on" or bXZipChecked = "on" ) then bDisplay = true
' Display all document in the folder is dangerous, so...
'if bAllChecked = "on" then bDisplay = true
if bDisplay = true then
' get this file's properties
suminfo.SetFile sPath & "/" & s
' first, display this file's icon & name
Response.Write "<TR><TD colspan=2 class='tablefilename'>"
' display icon according to file type
select case filetype
case "xls": RESPONSE.Write "<img SRC=" & VRoot & "/images/xls.gif WIDTH=16 HEIGHT=16 SPACE=11>"
case "doc": RESPONSE.Write "<img SRC=" & VRoot & "/images/doc.gif WIDTH=16 HEIGHT=16 SPACE=11>"
case "mdb": RESPONSE.Write "<img SRC=" & VRoot & "/images/mdb.gif WIDTH=16 HEIGHT=16 SPACE=11>"
case "ppt": RESPONSE.Write "<img SRC=" & VRoot & "/images/ppt.gif WIDTH=16 HEIGHT=16 SPACE=11>"
case "url": RESPONSE.Write "<img SRC=" & VRoot & "/images/url.gif WIDTH=16 HEIGHT=16 SPACE=11>"
case "zip": RESPONSE.Write "<img SRC=" & VRoot & "/images/txt.gif WIDTH=16 HEIGHT=16 SPACE=11>"
case else : RESPONSE.Write "<img SRC=" & VRoot & "/images/txt.gif WIDTH=16 HEIGHT=16 SPACE=11>"
end select
Response.Write "<span onmousemove='mousemove()' onmouseout='mouseout()'>"
Response.Write "<a href='" & sPath & "/" & s & "'></span>" & s & "</a>"
' it's funny that only ppt has bytes property
if filetype = "ppt" then Response.Write " (file size: " & suminfo.Bytes & ")"
' begin of function - to see if the doc is new, for example, in near 5 days
' there's once very important, to confirm that your system time looks like
' "Thursday, November 20, 1997, 5:02:45 PM"
' otherwise you'll get error
' to avoid the error, please change long time format to
' dddd, MM dd, yyyy
' on SC NT Server
'get first ","
dim sLST, iPos_fisrtcomm, iPos_secondcomm
' now it's like "Thursday, November 20, 1997, 5:02:45 PM"
sLST = suminfo.LastSaveTime
iPos_fisrtcomm = instr (1, sLST, ",")
' make it's like "November 20, 1997, 5:02:45 PM"
sLST = right (sLST ,(len(sLST)-iPos_fisrtcomm -1) )
' again, to get first "," & second ","
iPos_fisrtcomm = instr (1, sLST, ",")
iPos_secondcomm = instr ((iPos_fisrtcomm +1), sLST, ",")
' make it's like "November 20, 1997"
sLST = Left (sLST, iPos_secondcomm - 1)
if ((date - datevalue (sLST)) < 5) then Response.Write " <img src=" & VRoot & "/images/new.gif>"
' end of function - to see if the doc is new, for example, in near 5 days
Response.Write "</TR>"
' then, display nessesary properties one by one
'owner, ie, author
Response.Write "<TR class='tablefiledetail'>"
Response.Write "<TD align=right valign=top width='30%'><b>Owner</b></TD>"
Response.Write "<TD valign=top>"
Response.Write "<a href='mailto:" & suminfo.Author & "'><u>" & suminfo.Author & "</u></TD>"
'subject
Response.Write "<TR class='tablefiledetail'>"
Response.Write "<TD align=right valign=top><b>Subject</b></TD>"
Response.Write "<TD valign=top>" & suminfo.Subject & "</TD>"
'title
'Response.Write "<TR class='tablefiledetail'>"
'Response.Write "<TD align=right valign=top><b>Title</b></TD>"
'Response.Write "<TD valign=top>" & suminfo.Title& "</TD>"
'comments
Response.Write "<TR class='tablefiledetail'>"
Response.Write "<TD align=right valign=top><b>Comment</b></TD>"
Response.Write "<TD valign=top>" & suminfo.Comments & "</TD>"
Response.Write "</TD></TR>"
'last saved day
Response.Write "<TR class='tablefiledetail'>"
Response.Write "<TD align=right valign=top><b>Last Saved Day</b></TD>"
Response.Write "<TD valign=top>" & suminfo.LastSaveTime & "</TD>"
Response.Write "</TD></TR>"
'word doc page number (only for word doc)
if filetype = "doc" then
Response.Write "<TR class='tablefiledetail'>"
Response.Write "<TD align=right valign=top><b>Word Page Number:</b></TD>"
Response.Write "<TD valign=top>" & suminfo.PageCount & "</TD>"
Response.Write "</TD></TR>"
end if
'slides page number (only for ppt)
if filetype = "ppt" then
Response.Write "<TR class='tablefiledetail'>"
Response.Write "<TD align=right valign=top><b>Slides Page Number:</b></TD>"
Response.Write "<TD valign=top>" & suminfo.Slides & "</TD>"
Response.Write "</TD></TR>"
end if
end if
next
Response.Write "</TABLE>"
' Release Resource - Kill the Objects
set suminfo = Nothing
set f1 = Nothing
set fc = Nothing
set f = Nothing
set fs = Nothing
</SCRIPT>
</BODY>
</HTML>
=======================
……