莫相离 发表于 2015-1-16 22:33:22

ASP编程:ASP文件操纵--列出目次及文件

问题是他们究竟是喜欢他们是使用软件时,速度快还是速度慢好.(当然在3秒以内).无论是他们输入资料时,查找资料时,分析资料时.把以下文件建在统一目次,IIS中断定文件操纵组件可用,便可用ASP列出文件和目次了,呵呵接待到临我的主页http://skypavilion.yeah.net

----文件folder.inc-----
<%
folderini="c:"
%>


----文件index.asp-----
<!--#Includefile="folder.inc"-->
<html>
<head>
<title>FileSearch</title>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
</head>

<framesetrows="80,*"frameborder="1"border="1"framespacing="1"cols="*">
<framename="topFrame"scrolling="NO"src="up.asp">
<framename="mainFrame"src="getinfo.asp?foldinfo=<%=folderini%>">
</frameset>
<noframes><bodybgcolor="#FFFFFF">

</body></noframes>
</html>



----文件up.asp-----
<!--#Includefile="folder.inc"-->
<html><title>Up</title>
<head>
<styletype="text/css">
<!--
.ttl1_txt{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
.cnt_txt{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
A:link{color:#0000ff;text-decoration:none}
A:visited{color:#0000ff;text-decoration:none}
A:active{color:#33ccff;text-decoration:underline}
A:hover{color:#33ccff;text-decoration:underline}
body{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
Tr{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
TD{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt
-->
</style>

</head>
<tablewidth="780"border="0"cellspacing="1"cellpadding="1">
<tralign="center">
<tdalign="center"><ahref="getinfo.asp?foldinfo=<%=folderini%>"target="mainFrame">ListAllFolder/FileInfo</a>
</td>
</tr>
</table>
</html>



----文件getinfo.asp-----
<!--#Includefile="folder.inc"-->
<%foldinfo=trim(Request.Querystring("foldinfo"))%>
<html>
<head>
<title>GetInfo</title>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<styletype="text/css">
<!--
.ttl1_txt{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
.cnt_txt{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
A:link{color:#0000ff;text-decoration:none}
A:visited{color:#0000ff;text-decoration:none}
A:active{color:#33ccff;text-decoration:underline}
A:hover{color:#33ccff;text-decoration:underline}
body{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
Tr{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
TD{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt
-->
</style>
<ScriptLanguage="JavaScript">
functionfileinfo(filenamecode,filesize,lastmodify){
//document.write(filenamecode);
window.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");
}
</Script>
</head>

<bodybgcolor="#FFFFFF"text="#000000">
<tablewidth="780"border="0"cellspacing="0"cellpadding="0">
<tr>
<tdclass="cnt_txt"><fontcolor="#000000">CurrentFolder:--</font><fontcolor="#FF7120"><%=foldinfo%></font></td>
</tr>
<tr>
<td>
<hrsize="1">
</td>
</tr>
<tr>
<td>
<tablewidth="780"border="0"cellspacing="1"cellpadding="1">
<trbgcolor="#00CC00">
<tdwidth="300"class="cnt_txt">FolderName:</td>
<tdwidth="180"class="cnt_txt">Size:</td>
<tdwidth="300"class="cnt_txt">LastModify:</td>
</tr>
</table>
</td>
</tr>
<tr>
<tdalign="right"class="cnt_txt">
<%
upfolder=left(foldinfo,len(foldinfo)-1)
upfolder=left(upfolder,InstrRev(upfolder,""))
iffoldinfofolderinithen
response.write("<ahref=getinfo.asp?foldinfo="&upfolder&">ParentFolder</a>")
else
response.write("ParentFolder")
endif%>
</td>
</tr>
<tr>
<tdclass="cnt_txt">
<%ShowFolderList(foldinfo)%>
</td>
</tr>
<tr>
<tdclass="cnt_txt">
<tablewidth="780"border="0"cellspacing="1"cellpadding="1">
<trbgcolor="#009999">
<tdwidth="300">FileName:</td>
<tdwidth="180">Size:</td>
<tdwidth="300">LastModify:</td>
</tr>
</table>
</td>
</tr>
<tr>
<tdclass="cnt_txt">
<%showfolderinfo(foldinfo)%>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>

<%
SubShowFolderList(folderspec)
Dimfs,f,f1,fc,s,schild,p,fsize
Setfs=CreateObject("Scripting.FileSystemObject")
Setf=fs.GetFolder(folderspec)
Setfc=f.SubFolders
ForEachf1infc
s=f1.name
s=s&vbCrLf
p=f1.DateLastModified
fsize=f1.Size
schild=folderspec&s&""

Response.write("<tablewidth=780border=0cellspacing=1cellpadding=1>")
Response.write("<tr>")
Response.write("<tdwidth=300bgcolor=#ECFFD9><fontface=Wingdingsfontsize=3pt>0</font><ahref=getinfo.asp?foldinfo="&schild&">"&s&"</a></td>")
Response.write("<tdwidth=180bgcolor=#ECFFD9>"&fsize&"</td>")
Response.write("<tdwidth=300bgcolor=#ECFFD9>"&p&"</td>")
Response.write("</tr>")
Response.write("</table>")

Next
EndSub

Subshowfolderinfo(folderspc)
setMyFileObject=Server.CreateObject("Scripting.FileSystemObject")


SetMyFolder=MyFileObject.GetFolder(folderspc)

foreachthinginMyFolder.Files
Response.write("<br>"&thing)
===============Getfileinformation
Setafile=MyFileObject.GetFile(thing)

==========filenamecorrectcode
filenamecode=afile.name
filedetail=folderspc+filenamecode
filedetail=replace(filedetail,"","*s_p_l_i_t*")
filesize=afile.size
lastmodify=afile.DateLastModified

Response.write("<tablewidth=780border=0cellspacing=1cellpadding=1>")
Response.write("<tr>")
Response.write("<tdwidth=300bgcolor=#f4f4ff><fontface=Wingdingsfontsize=3pt><</font><ahref="&chr(34)&"javascript:fileinfo("&filedetail&","&filesize&","&lastmodify&")"&chr(34)&">"&filenamecode&"</a></td>")
Response.write("<tdwidth=180bgcolor=#f4f4ff>"&filesize&"</td>")
Response.write("<tdwidth=300bgcolor=#f4f4ff>"&lastmodify&"</td>")
Response.write("</tr>")
Response.write("</table>")
Next
Endsub
%>
</body>
</html>


----文件fileinfo.asp-----
<%
filename=Request.QueryString("filename")
filename=replace(filename,"*s_p_l_i_t*","")
filesize=Request.QueryString("filesize")
lastmodify=Request.QueryString("lastmodify")
%>
<html>
<head>
<styletype="text/css">
<!--
.ttl1_txt{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
.cnt_txt{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
A:link{color:#0000ff;text-decoration:none}
A:visited{color:#0000ff;text-decoration:none}
A:active{color:#33ccff;text-decoration:underline}
A:hover{color:#33ccff;text-decoration:underline}
body{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
Tr{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt}
TD{font-family:"Verdana","Arial","Helvetica","sans-serif";font-size:9pt
-->
</style>
</head>
<body>
<%
Response.writefilename&"<br>"&filesize&"<br>"&lastmodify
%>
<tablewidth="400"border="0"cellspacing="0"cellpadding="0">
<tr>
<tdbgcolor="#00CC00"colspan="2">CurrentFileInfo:</td>
</tr>
<trvalign="top">
<tdwidth="110">FileLocation:</td>
<tdwidth="290"><fontcolor="#990000"><fontface=Wingdingsfontsize=3pt><</font><b><%=filename%></b></font></td>
</tr>
<tr>
<tdcolspan="2">
<hrsize="1">
</td>
</tr>
<trvalign="top">
<tdheight="11">FileSize:</td>
<tdheight="11"><%=filesize%>bytes</td>
</tr>
<tr>
<tdcolspan="2">
<hrsize="1">
</td>
</tr>
<trvalign="top">
<td>LastModify:</td>
<td><%=lastmodify%></td>
</tr>
<tr>
<tdcolspan="2">
<hrsize="1">
</td>
</tr>
<tr>
<tdheight="18"colspan="2">
<p>PleaseUseappropriateApplicationtoOpenthisFile.</p>
</td>
</tr>
<tr>
<tdheight="13"align="right"colspan="2"><ahref="javascript:this.window.close()">Close
Window</a></td>
</tr>
</table>
</body>
</html>


写软件都是想的时间比写的时间要长的.如果反过来了就得看看是什么原因了.另外大家可以回去问问公司里的小MM.(一般企业里,跟你们交付软件接触得最多的是她们)

透明 发表于 2015-1-18 07:59:11

接下来就不能纸上谈兵了,最好的方法其实是实践。实践,只能算是让你掌握语言特性用的。而提倡做实际的Project也不是太好,因为你还没有熟练的能力去综合各种技术,这样只能使你自己越来越迷糊。

谁可相欹 发表于 2015-1-21 13:49:21

我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。

乐观 发表于 2015-1-30 19:36:37

ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。

柔情似水 发表于 2015-2-6 15:28:16

学习是为了用的,是为了让你的程序产生价值,把握住这个原则会比较轻松点。除此之外,课外时间一定要多参加一些社会实践活动,来锻炼自己的能力。

精灵巫婆 发表于 2015-2-16 21:28:29

掌握asp的特性而且一定要知道为什么。

若相依 发表于 2015-3-5 09:39:10

那么,ASP.Net有哪些改进呢?

因胸联盟 发表于 2015-3-19 17:53:36

ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。
页: [1]
查看完整版本: ASP编程:ASP文件操纵--列出目次及文件