最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP编程要点ABC之一
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
使用Server.MapPath
尽可能地使用Server.MapPath()来表示存储在服务器上的文件,而不要用静态绝对路径。因为,如果采用静态绝对路径,当web路径发生变化时,将导致文件路径表达错误,从而不得不修改原静态路径。而使用Server.MapPath()表示的路径就不必再做修改。
比如,以下的代码就不是好的方法:
< %
whichfile="D:inetpubwwwrootwhateverjunk.txt"
set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(whichfile, 1, False)
tempSTR=thisfile.readall
response.write tempSTR
thisfile.Close
set thisfile=nothing
set fs=nothing
% >
建议使用下面的代码来完成同样的功能:
< %
whichfile=server.mappath("whateverjunk.txt")
set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(whichfile, 1, False)
tempSTR=thisfile.readall
response.write tempSTR
thisfile.Close
set thisfile=nothing
set fs=nothing
% >
-
上一个: 新闻中限制显示字数目
-
下一个: 蛙蛙推荐:巧用缓存提高asp程序的性能
相关文章
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- asp中获取日期为星期几的技巧 09-14
- Asp编码优化参考 09-14
- .Net Core认证系统源码解析 12-26
- SharePoint Server 2019新特性介绍 01-15