读取目录下的所有文件(源码)
类别: ASP教程
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
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
- 上一篇: 制作我们自己的EBAY(拍卖系统)(7)
- 下一篇: 用ASP做一个记事本编缉器(附源码)
-= 资 源 教 程 =-
文 章 搜 索