当前位置: 首页 > 图文教程 > 网络编程 > ASP > 读取目录下的所有文件(源码)

ASP
用ASP实现对Web搜索引擎Index Server的访问
ASP.NET数据库应用指南
利用ASP存取各种常用类型数据库(1)
利用ASP存取各种常用类型数据库(2)
利用ASP存取各种常用类型数据库(3)
利用ASP存取各种常用类型数据库(4)
利用ASP存取各种常用类型数据库(5)
利用ASP存取各种常用类型数据库(6)
一个简单的网上书城的例子(一)
一个简单的网上书城的例子(二)
一个简单的网上书城的例子(三)
一个简单的网上书城的例子(四)
一个简单的网上书城的例子(五)
一个简单的网上书城的例子(六)
一个简单的网上书城的例子(七)
一个简单的网上书城的例子(八)
用asp怎样编写文档搜索页面(1)
用asp怎样编写文档搜索页面(2)
用asp怎样编写文档搜索页面(3)
用asp怎样编写文档搜索页面(4)

ASP 中的 读取目录下的所有文件(源码)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 38 ::
收藏到网摘: n/a

  Many times we might need some part of code which will access all sub-folders of the server and also all
     files within the sub-folder.
     The following line of asp code will map to a specified folder and searches all the sub-folders
     (Not recursively, code can be extended to do) and reads all files(basically text files) one by one.
     
     You can specify any folder name, in the remarks given in the code (within " ")
     
     'Create a File system Object
     set FileSystem=server.CreateObject("scripting.filesystemobject")
     
     dim dbconn
     
     folderpath=server.MapPath("main Folder path" )
     set sfolder=Filesystem.GetFolder(folderpath).SubFolders
     for each FolderItem in sfolder
     set Files=FolderItem.Files
     for each FileItem in Files
     fname=server.MapPath( "main folder path" & FolderItem.Name & "\" & FileItem.Name
     set File=FileSystem.OpenTextFile(fname,1,false)
     while File.AtEndofStream <> True
     record=split(File.Readline,"~")
     wend
     File.close
     FileSystem.DeleteFile(fname)
     next
     next