读取目录下的所有文件(包括子目录下的所有文件)_ASP教程-查字典教程网
读取目录下的所有文件(包括子目录下的所有文件)
读取目录下的所有文件(包括子目录下的所有文件)
发布时间:2016-12-29 来源:查字典编辑
摘要:******************************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教程学习
    热门ASP教程学习
    编程开发子分类