手机
当前位置:查字典教程网 >编程开发 >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

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

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

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

另类的文件上传解决方案

利用AdoDb.Stream对象来读取UTF-8格式的文本文件

用ASP读取XML文件的具体方法与示例

用asp实现的数据库中存取文件的代码

信息发布中的判断过期和有效期的东西

取得表单提交的所有数据

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

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

文件、目录,文本文件等多种操作类

精品推荐
分类导航