手机
当前位置:查字典教程网 >编程开发 >ASP教程 >读取目录下的所有文件(包括子目录下的所有文件)
读取目录下的所有文件(包括子目录下的所有文件)
摘要:******************************Manytimeswemightneedsomepartofcodewhichw...

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

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

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

【读取目录下的所有文件(包括子目录下的所有文件)】相关文章:

ASP,FSO遍历目录及目录下文件

关于网站文件自动备份程序的一点思考

asp下实现替换远程文件为本地文件并保存远程文件的代码

遍历目录以及目录下文件的函数

ASP中生成文本文件的两种方式

vithink小文件自动实现文件浏览下载

asp 文件上传aspjpeg组件上传文件

非常不错的列出sql服务器上所有数据库的asp代码

ASP中文本文件与数据库文件的数据交换(FSO)

对文件的操作--建立移动删除文件夹

精品推荐
分类导航