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

在ASP中利用ADO显示Excel文件内容的函数

取得表单提交的所有数据

用ASP打开远端MDB文件的方法

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

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

FileSystem对象常用的文件操作函数有哪些?

怎样判断一个盘上是否有文件

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

精品推荐
分类导航