asp實現(xiàn)遍歷文件夾下的所有文件
?
關(guān)鍵詞
asp實現(xiàn)遍歷文件夾下的所有文件
?
摘要
我們這里通過遍歷一個文件夾下的文件來生成一個sitemap.txt文件,代碼如下:
<%
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set fsd=fso.getfolder(server.mappath("../test/"))
Set fs=fso.openTextFile(Server.mappath("/sitemap.txt"),8,true)
Set fsfiles=fsd.Files
For Each fsfile In fsfiles
? ?tmpPath="http://www.test.com/test/" & fsFile.name
? ?fs.writeLine tmpPath
Next
response.write "<p>Create Sitemap.txt Successfully !"
set fsfiles=nothing
set fs=nothing
set fsd=nothing
set fso=nothing
%>
我們這里通過遍歷一個文件夾下的文件來生成一個sitemap.txt文件,代碼如下:
<%
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set fsd=fso.getfolder(server.mappath("../test/"))
Set fs=fso.openTextFile(Server.mappath("/sitemap.txt"),8,true)
Set fsfiles=fsd.Files
For Each fsfile In fsfiles
? ?tmpPath="http://www.test.com/test/" & fsFile.name
? ?fs.writeLine tmpPath
Next
response.write "<p>Create Sitemap.txt Successfully !"
set fsfiles=nothing
set fs=nothing
set fsd=nothing
set fso=nothing
%>
?