1. 程式人生 > >fso獲取資料夾下檔案個數和顯示檔名(無後綴)

fso獲取資料夾下檔案個數和顯示檔名(無後綴)

 感謝sayhito333提供給我這段程式碼,為表示感謝,不修改其宣傳性的函式名了,呵呵!

<%
path = "database/"
sub sayhito333(path)
dim fso
dim objFolder
dim objFiles
dim

objFile
dim n

set fso=server.CreateObject("scripting.filesystemobject")
set

objFolder=fso.GetFolder(Server.MapPath(path))
set objFiles=objFolder.Files
Response.Write

"資料夾"&path&"包含的檔案個數為:"
Response.Write objFiles.count&"個<br>"
for each

objFile in objFiles

n=instr(objFile.name,".")
Response.Write "---"&Left(objFile.name,n-

1)&"<br>"
next
set objFile=nothing
set objFiles=nothing
set objFolder=nothing
set

fso=nothing
end sub

call sayhito333(path)
%>