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

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了读取目录下的所有文件(包括子目录下的所有文件)脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
******************************

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


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

脚本宝典总结

以上是脚本宝典为你收集整理的读取目录下的所有文件(包括子目录下的所有文件)全部内容,希望文章能够帮你解决读取目录下的所有文件(包括子目录下的所有文件)所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: