读取目录下的所有文件(源码)
发布时间:2006-10-14 2:39:58   收集提供:gaoqian
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
     
     
     
     
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50