Read all files under the directory (including all files under subdirectories)
Source: Internet
Author: User
******************************
Many we might need some part of code which'll access all sub-folders the the server and also all
The files within the sub-folder.
The following line of ASP code would map to a specified folder and searches all the sub-folders
(not recursively, code can is extended to does) and reads all files (basically-text files) one by one.
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
******************************
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.