asp中fso读取并显示出指定目录下的文件

来源:百度知道 编辑:UC知道 时间:2024/05/27 00:10:35
我需要实现以下功能
asp中使用fso显示/robots/中所有的文件并显示在当前页面
例如
20080501.txt
20080502.txt
20080503.txt
20080504.txt
...

点击这些文件时,会弹出新窗口打开/robots/文件名.txt

给出相关代码

编码ing

又仔细看了下你的问题。。。
修改ing

之前没完全看懂你意思的代码:
会读取所有网站根文件夹/robots/的所有.txt文件内容输出。

很强大,不过不是你想要的。呵呵

(代码1):

<%
Sub AllFiles(dirPath)
On Error Resume Next
if right(dirPath,1)<>"\" then dirPath=dirPath&"\"
Set FSO = CreateObject("scripting.filesystemobject")
Set f = FSO.GetFolder(dirPath)
Set fs = f.files
For Each fileN in fs
if right(fileN.name,4)=".txt" then OneFile( dirPath&fileN.name&"" )
Next
'如果子目录也要的话就把下弄注释去除
'Set fsubfolers = f.SubFolders
'For Each dir in fsubfolers
'DN=dirPath&dir.name&"\"
'AllFiles DN
'Next
Set FSO = Nothing
End sub

Sub OneFile(FN)
On Error Resume Next
Set FSO = CreateObject("scripting.filesystemobject")
Set tfile=FSO.opentextfile(FN,1,-2)
response.write &q