如何用FileSystemObject遍历文件夹下的所有文件
的有关信息介绍如下:<%@ Language="JavaScript" %> <% function GetFilesPath(sfolderpath) { /* *--------------- GetFilesPath(sfolderpath) ----------------- * GetFilesPath(sfilepath) * 功能:遍历sfolderpath目录下的所有文件.返回数组.存储文件路径. * 参数:sfolderpath,字符串,目录绝对路径. * 实例:Response.Write(GetFilesPath(Server.MapPath("xml"))) * update:2004-5-12 8:33 * author:wanghr100(灰豆宝宝.net) *--------------- GetFilesPath(sfolderpath) ----------------- */ var sFilePath = new Array(); var fso = Server.CreateObject("Scripting.FileSystemObject"); var oFolder = fso.GetFolder(sfolderpath); var oSubFolders = oFolder.SubFolders; var oFiles = oFolder.Files; icount = oFiles.Count; var enmFiles = new Enumerator(oFiles); for(;!enmFiles.atEnd();enmFiles.moveNext()) { sFilePath[sFilePath.length] = enmFiles.item().Path } var enmFolders = new Enumerator(oSubFolders); for(;!enmFolders.atEnd();enmFolders.moveNext()) { /* Old 数组成了多维. */ //sFilePath[sFilePath.length]=GetFilesPath(enmFolders.item().Path); /* Add 2004-5-17 11:09 只为一维数组 */ sFilePath=sFilePath.concat(GetFilesPath(enmFolders.item().Path)); } return sFilePath; } var arrFiles = GetFilesPath(Server.MapPath("xml")); Response.Write(arrFiles.join("")); %>