把以下文件建在同一目录,IIS中确定文件操作组件可用,即可用ASP列出文件和目录了,呵呵欢迎光临我的主页 http://skypavilion.yeah.net
----文件folder.inc-----
1
2folderini="c:\"
----文件index.asp-----
1<html>
2<head>
3<title>FileSearch</title>
4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
5</head>
6<frameset border="1" cols="*" frameborder="1" framespacing="1" rows="80,*">
7<frame name="topFrame" scrolling="NO" src="up.asp"/>
8<frame name="mainFrame" src="getinfo.asp?foldinfo=```
9=folderini
10```"/>
11</frameset>
12<noframes><body bgcolor="#FFFFFF">
13</body></noframes>
14</html>
----文件up.asp-----
1<html><title>Up</title>
2<head>
3<style type="text/css">
4<!--
5.ttl1_txt { font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
6.cnt_txt { font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
7A:link{color:#0000ff;text-decoration: none}
8A:visited {color:#0000ff;text-decoration: none}
9A:active {color:#33ccff;text-decoration: underline}
10A:hover {color:#33ccff;text-decoration: underline}
11body{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
12Tr{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
13TD{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt
14\-->
15</style>
16</head>
17<table border="0" cellpadding="1" cellspacing="1" width="780">
18<tr align="center">
19<td align="center"><a href="getinfo.asp?foldinfo=```
20=folderini
21```" target="mainFrame">List All Folder/File Info</a>
22</td>
23</tr>
24</table>
25</html>
----文件getinfo.asp-----
1foldinfo=trim(Request.Querystring("foldinfo"))
1<html>
2<head>
3<title>GetInfo</title>
4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
5<style type="text/css">
6<!--
7.ttl1_txt { font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
8.cnt_txt { font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
9A:link{color:#0000ff;text-decoration: none}
10A:visited {color:#0000ff;text-decoration: none}
11A:active {color:#33ccff;text-decoration: underline}
12A:hover {color:#33ccff;text-decoration: underline}
13body{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
14Tr{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
15TD{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt
16\-->
17</style>
18<script language="JavaScript">
19function fileinfo(filenamecode,filesize,lastmodify){
20//document.write(filenamecode);
21window.open("fileinfo.asp?filename="+filenamecode+"&filesize="+filesize+"&lastmodify="+lastmodify,"","height=200,width=450,resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no");
22}
23</script>
24</head>
25<body bgcolor="#FFFFFF" text="#000000">
26<table border="0" cellpadding="0" cellspacing="0" width="780">
27<tr>
28<td class="cnt_txt"> <font color="#000000">Current Folder:--</font><font color="#FF7120">```
29=foldinfo
30```</font></td>
31</tr>
32<tr>
33<td>
34<hr size="1"/>
35</td>
36</tr>
37<tr>
38<td>
39<table border="0" cellpadding="1" cellspacing="1" width="780">
40<tr bgcolor="#00CC00">
41<td class="cnt_txt" width="300">Folder Name:</td>
42<td class="cnt_txt" width="180">Size:</td>
43<td class="cnt_txt" width="300">LastModify:</td>
44</tr>
45</table>
46</td>
47</tr>
48<tr>
49<td align="right" class="cnt_txt">
upfolder=left(foldinfo,len(foldinfo)-1)
upfolder=left(upfolder,InstrRev(upfolder, ""))
if foldinfo<>folderini then
response.write("<a href='getinfo.asp?foldinfo="&upfolder&"'>Parent Folder</a>")
else
response.write("Parent Folder")
end if
1</td>
2</tr>
3<tr>
4<td class="cnt_txt">
ShowFolderList(foldinfo)
1</td>
2</tr>
3<tr>
4<td class="cnt_txt">
5<table border="0" cellpadding="1" cellspacing="1" width="780">
6<tr bgcolor="#009999">
7<td width="300">File Name:</td>
8<td width="180">Size:</td>
9<td width="300">LastModify:</td>
10</tr>
11</table>
12</td>
13</tr>
14<tr>
15<td class="cnt_txt">
showfolderinfo(foldinfo)
1</td>
2</tr>
3<tr>
4<td> </td>
5</tr>
6</table>
7
Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s, schild,p,fsize
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
s = f1.name
's = s & vbCrLf
p = f1.DateLastModified
fsize = f1.Size
schild=folderspec&s&""
Response.write("<table border="0" cellpadding="1" cellspacing="1" width="780">")
Response.write("<tr>")
Response.write("<td bgcolor="#ECFFD9" width="300"><font face="Wingdings" font="" size="3pt">0</font><a href='getinfo.asp?foldinfo="&schild&"'>"&s&"</a></td>")
Response.write("<td bgcolor="#ECFFD9" width="180">"&fsize&"</td>")
Response.write("<td bgcolor="#ECFFD9" width="300">"&p&"</td>")
Response.write("</tr>")
Response.write("</table>")
Next
End Sub
Sub showfolderinfo(folderspc)
set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyFolder=MyFileObject.GetFolder(folderspc)
for each thing in MyFolder.Files
'Response.write("<br/>"&thing)
'===============Get file information
Set afile=MyFileObject.GetFile(thing)
'==========filename correct code
filenamecode=afile.name
filedetail=folderspc+filenamecode
filedetail=replace(filedetail,"","s_p_l_i_t")
filesize=afile.size
lastmodify=afile.DateLastModified
Response.write("<table border="0" cellpadding="1" cellspacing="1" width="780">")
Response.write("<tr>")
Response.write("<td bgcolor="#f4f4ff" width="300"><font face="Wingdings" font="" size="3pt"><</font><a href="&chr(34)&" javascript:fileinfo('"&filedetail&"','"&filesize&"','"&lastmodify&"')"&chr(34)&"="">"&filenamecode&"</a></td>")
Response.write("<td bgcolor="#f4f4ff" width="180">"&filesize&"</td>")
Response.write("<td bgcolor="#f4f4ff" width="300">"&lastmodify&"</td>")
Response.write("</tr>")
Response.write("</table>")
Next
End sub
1</body>
2</html>
----文件fileinfo.asp-----
1
2filename=Request.QueryString("filename")
3filename=replace(filename,"*s_p_l_i_t*","\")
4filesize=Request.QueryString("filesize")
5lastmodify=Request.QueryString("lastmodify")
1<html>
2<head>
3<style type="text/css">
4<!--
5.ttl1_txt { font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
6.cnt_txt { font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
7A:link{color:#0000ff;text-decoration: none}
8A:visited {color:#0000ff;text-decoration: none}
9A:active {color:#33ccff;text-decoration: underline}
10A:hover {color:#33ccff;text-decoration: underline}
11body{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
12Tr{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt}
13TD{font-family: "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 9pt
14\-->
15</style>
16</head>
17<body>
'Response.write filename&"<br/>"&filesize&"<br/>"&lastmodify
1<table border="0" cellpadding="0" cellspacing="0" width="400">
2<tr>
3<td bgcolor="#00CC00" colspan="2">Current File Info:</td>
4</tr>
5<tr valign="top">
6<td width="110">File Location:</td>
7<td width="290"><font color="#990000"><font face="Wingdings" font="" size="3pt"><</font><b> ```
8=filename
9```</b></font></td>
10</tr>
11<tr>
12<td colspan="2">
13<hr size="1"/>
14</td>
15</tr>
16<tr valign="top">
17<td height="11">File Size: </td>
18<td height="11">```
19=filesize
20``` bytes</td>
21</tr>
22<tr>
23<td colspan="2">
24<hr size="1"/>
25</td>
26</tr>
27<tr valign="top">
28<td>LastModify: </td>
29<td>```
30=lastmodify
31```</td>
32</tr>
33<tr>
34<td colspan="2">
35<hr size="1"/>
36</td>
37</tr>
38<tr>
39<td colspan="2" height="18">
40<p>Please Use appropriate Application to Open this File.</p>
41</td>
42</tr>
43<tr>
44<td align="right" colspan="2" height="13"><a href="javascript:this.window.close()">Close
45Window</a></td>
46</tr>
47</table>
48</body>
49</html>