急:关于文件的问题

orson 2004-08-02 05:32:56
怎么在网页中直接打开c:\test.txt文件
...全文
100 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
orson 2004-08-03
  • 打赏
  • 举报
回复
多谢各位解答!
再想问一下,假如我想直接打开到D:盘呢
用 aspczlover(执子之手...)的试了一下
<a href="D:\" target="_blank">test.txt</a> 保存为test.asp 结果却发现运行
http://localhost/a/test.asp 可以链接到D:盘目录,但运行
http://127.0.0.1/a/test.asp 确没反应,也就是没链接到D:盘目录

请问各位大侠,这个怎么回事????
怎么解决,分不够再加

ycted 2004-08-03
  • 打赏
  • 举报
回复
用fso吧.Jaron的代码就可以了.
19az 2004-08-03
  • 打赏
  • 举报
回复
同意 xzq686(瞬) 的说法
aspczlover 2004-08-03
  • 打赏
  • 举报
回复
<a href="c:\test.txt">test.txt</a>
seraphgxh 2004-08-03
  • 打赏
  • 举报
回复
response.redirect "c:\test.txt"
xzq686 2004-08-03
  • 打赏
  • 举报
回复
在虚拟目录中直接打开即可。
不在,则只能用FSO打开了。。,
另外FSO只能对虚拟目录以外的文件有只读操作。。
myxl 2004-08-03
  • 打赏
  • 举报
回复
会出现IE安全提示
Jaron 2004-08-03
  • 打赏
  • 举报
回复
上面有的点小错误,修正一下

use fso or xp_cmdshell(SqlServer)

'FSO
response.write getfulltext("c:\test.txt","不能打开文件")

Function getfulltext(ByVal full_filename, errortips)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(full_filename) Then
Set objCountFile = objFSO.OpenTextFile(full_filename, 1, True)
If Not objCountFile.AtEndOfStream Then getfulltext = objCountFile.ReadAll
Set objCountFile = Nothing
Else
getfulltext = errortips
End If
Set objFSO = Nothing
End Function

'xp_cmdshell

exec dbo.xp_cmdshell 'type c:\test.txt'
Jaron 2004-08-03
  • 打赏
  • 举报
回复
use fso or xp_cmdshell(SqlServer)

'FSO
response.write getfulltext("c:\test.txt")

Function getfulltext(ByVal full_filename, errortips)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(full_filename) Then
Set objCountFile = objFSO.OpenTextFile(full_filename, 1, True)
If Not objCountFile.AtEndOfStream Then getfulltext = objCountFile.ReadAll
Set objCountFile = Nothing
Else
getfulltext = errortips
End If
Set objFSO = Nothing
End Function

'xp_cmdshell

exec dbo.xp_cmdshell 'type c:\test.txt'
xiaobird1 2004-08-02
  • 打赏
  • 举报
回复
如果txt在虚拟目录中,直接访问即可显示。

如果不是,需要用fso读出后,再显示。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧