电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> Vbscript>>SP中保存数组到Application,并循环读取application里的所有数据:

SP中保存数组到Application,并循环读取application里的所有数据

来源:网络 | 2014-11-5 | (有1778人读过)

和大家分享一个ASP里查看指定文件源文件内容的ASP函数,先来看函数的内容:

SUB PrintLine (ByVal strLine)
    strLine=server.HTMLEncode(strLine)
    strLine=replace(strLine,"<%","<FONT COLOR=#ff0000><%")
    strLine=replace(strLine,"%>","%></FONT>")
    strLine=replace(strLine,"<SCRIPT","<FONT COLOR=#0000ff><SCRIPT",1,-1,1)
    strLine=replace(strLine,"</SCRIPT>","</SCRIPT></FONT>",1,-1,1)
    strLine=replace(strLine,"<!--","<FONT COLOR=#008000><!--",1,-1,1)
    strLine=replace(strLine,"-->","--></FONT>",1,-1,1)
    Response.Write strLine
END SUB
Function ShowCode(filename)
    Dim strFilename
    Dim FileObject, oInStream, strOutput    
    strFilename = filename
    Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
    Set oInStream = FileObject.OpenTextFile(strFilename, 1, 0, 0 )
    While NOT oInStream.AtEndOfStream
        strOutput = oInStream.ReadLine
        Call PrintLine(strOutput)
        Response.Write("<BR>")
    Wend
end function

接着再来看一个简单的实例:

<%
on error resume next
dim file
file=request.form("filename")
response.write file & "源程序如下<hr>"
if trim(file)<> "" then
  call showcode(file)
end if
%>

以上就是ASP里查看指定文件源文件内容的完整代码了,其实也没有什么难点,相信大家看了代码就能明白其中的意思!

Vbscript热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号