主页 > 知识库 > 读取目录下的所有文件(包括子目录下的所有文件)

读取目录下的所有文件(包括子目录下的所有文件)

热门标签:科大讯飞语音识别系统 服务器配置 银行业务 Linux服务器 阿里云 Mysql连接数设置 电子围栏 团购网站
******************************

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


******************************

标签:广元 衡水 蚌埠 枣庄 江苏 衢州 萍乡 大理

巨人网络通讯声明:本文标题《读取目录下的所有文件(包括子目录下的所有文件)》,本文关键词  ;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 收缩
    • 微信客服
    • 微信二维码
    • 电话咨询

    • 400-1100-266