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

ASP
深入讲解 ASP+ 验证(一)
深入讲解 ASP+ 验证(二)
深入讲解 ASP+ 验证(三)
深入讲解 ASP+ 验证(四)
通过事例学习.net的WebForms技术(一)
通过事例学习.net的WebForms技术(二)
StripNonNumeric函数源程序
通过事例学习.net的WebForms技术(三)
通过事例学习.net的WebForms技术(四)
将HTML表单数据存储为XML格式 - 1
将HTML表单数据存储为XML格式 - 2
将HTML表单数据存储为XML格式 - 3
asp生日自动提醒小程式
WEB页面简单进度记时器
在主页中编制音频播放器
图片数据的存和取示例
用ASPMail组件实现E_mail自动反馈
读取目录下的所有文件(源码)
制作我们自己的Ebay(拍卖系统)(1)
制作我们自己的Ebay(拍卖系统)(2)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 23 ::
收藏到网摘: 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