程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> 讀取目錄下的所有文件(包括子目錄下的所有文件)

讀取目錄下的所有文件(包括子目錄下的所有文件)

編輯:關於ASP編程
******************************

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. 下一頁:
Copyright © 程式師世界 All Rights Reserved