| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 841 人关注过本帖
标题:[求助] 如何用asp实现下载功能??附代码
取消只看楼主 加入收藏
topsun321
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-4-26
收藏
 问题点数:0 回复次数:1 
[求助] 如何用asp实现下载功能??附代码

实现下载功能的程序代码如下:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body>
 <script src=http://www.mithink.com/js/top.js></script>
<table id="table16" cellSpacing="0" cellPadding="0" width="765" border="0">
<tr>
<td vAlign="bottom" align="middle" colSpan="2">
<table id="table21" cellSpacing="0" cellPadding="0" width="765" align="center" border="0">
<tr>
<td ><%
Set FSO = CreateObject("scripting.FileSystemObject")

hu = Replace(Server.MapPath("default.asp"),"default.asp","")''本系统所在目录

Set TestFolder = FSO.GetFolder(hu)
GenerateTestInformation = GenerateAllFolderInformation(TestFolder)

Function GenerateAllFolderInformation(Folder)

Dim S, SubFolders, SubFolder, Files, File, i
tmpStr = ""
Set SubFolders = Folder.SubFolders


If SubFolders.Count <> 0 Then
i = 1
For Each SubFolder In SubFolders
i = i + 1
tmpStr = tmpStr & GenerateFolderInformation(SubFolder,i)
Next
End If
Response.Write tmpStr & "</table><br>"
tmpStr = ""
Set Files = Folder.Files

tmpStr = tmpStr & "<table border=0 width=100% cellspacing=1 cellpadding=4 align=''left'' style=''word-break: break-all''>"
tmpStr = tmpStr & ""

If Not (Folder.IsRootFolder) Then
tmpStr = tmpStr & ""
End If
tmpStr = tmpStr & ""
tmpStr = tmpStr & ""


If Files.Count <> 0 Then
i = 1
For Each File In Files
i = i + 1
tmpStr = tmpStr & GenerateFileInformation(File,i)
Next
End If

Response.Write tmpStr & "</table>"

End Function


Function UrlEnCode(Path)
UrlEnCode = Replace(Server.URLEncode(Path),"\","/")
End Function

Function CloseFSO
FSO.Close
Set FSO = Nothing
End Function

Function GenerateFileInformation(File,i)

Dim S, RowColor

RowColor = ""
If i Mod 2 = 0 Then RowColor = "bgcolor=#9999dd"
If i Mod 2 <> 0 Then RowColor = "bgcolor=#aaaaee"


S = "<tr><td "&RowColor&" > " & File.Name & "</td>"
S = S & "<td "&RowColor&">" & FormatNumber(File.Size/1024 ,0) & " KB</td>"

S = S & "<td align=center "&RowColor&">"

S = S & "<a href=''" & File.Name & "'' > ↓</a></td></tr>"

GenerateFileInformation = S

End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 函数名称:GenerateFolderInformation()
'' 功能说明:描述文件夹的当前状态

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GenerateFolderInformation(Folder,i)

Dim S, RowColor

RowColor = ""
If i Mod 2 = 0 Then RowColor = "bgcolor=#dddddd"


S = ""


GenerateFolderInformation = S

End Function

%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script src=http://www.mithink.com/js/bottom1.js></script>

</body>

</html>
执行结果如下:
 

程序代码:
<SCRIPT src=\"http://www.mithink.com/js/top.js\">

chkemail.asp 1 KB
default.asp 3 KB
DOWNLOAD.ASP 3 KB
Faq.asp 2 KB
FaqInfo.asp 2 KB
font.css 1 KB
Global.asa 1 KB
guestbook.asp 1 KB
guestbookadd.asp 1 KB
guestbooksave.asp 1 KB
index.htm KB
Intro.asp 2 KB
main.asp 3 KB
msgadddat.asp 4 KB
msgshowdat.asp 3 KB
News.asp 2 KB
NewsInfo.asp 1 KB
NewsInfodat.asp 1 KB
Product.asp 2 KB
ProductInfo.asp 1 KB
Search.asp 2 KB
Styles.css 3 KB
template.asp 1 KB
trfsoft.sln 1 KB
trfsoft.suo 10 KB
trfsoft.vbproj 39 KB
trfsoft.vbproj.webinfo KB
WebForm1.aspx 10 KB
WebForm1.aspx.resx 5 KB
WebForm1.aspx.vb 1 KB
配置.txt 1 KB
2006-05-14 00:15
topsun321
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-4-26
收藏
得分:0 

大虾你点击在新窗口中查看按纽就好了啊,帮帮忙哦

2006-05-14 14:50
快速回复:[求助] 如何用asp实现下载功能??附代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052928 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved