Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > asp技巧

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

来源:中文源码网    浏览:143 次    日期:2024-05-18 01:01:05
【下载文档:  读取目录下的所有文件(包括子目录下的所有文件).txt 】


读取目录下的所有文件(包括子目录下的所有文件)
******************************
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
******************************

相关内容