Use asp to read the list of objects in a specified folder (xml is returned)

Source: Internet
Author: User

The following is the asp code for reading all files (excluding subfolders) in the specified folder. xml is returned to facilitate interaction with flex.

 

'Create a FileSystemObject object example
Set MyFileObject = Server. CreateObject ("Scripting. FileSystemObject ")
'Create a Folder object
Foldername = server. mappath ("folder under server ./")
Set MyFolder = MyFileObject. GetFolder (foldername)

Str = "<? Xml version = '1. 0' encoding = 'utf-8'?> "& Vbcrlf &" <root> "& vbcrlf
'Put two raw data first to prevent bugs in interaction between only one record and flex (provided that at least one record exists in the folder, otherwise there will still be bugs)
Str = str & "<file>" & vbcrlf
Str = str & "<name> henhenhahi </name>" & vbcrlf
Str = str & "</file>" & vbcrlf
Str = str & "<file>" & vbcrlf
Str = str & "<name> henhenhahi, too </name>" & vbcrlf
Str = str & "</file>" & vbcrlf
'Show objects cyclically
I = 0
For Each thing in MyFolder. Files
Str = str & "<file>" & vbcrlf
Str = str & "<name>" & thing & "</name>" & vbcrlf
Str = str & "</file>" & vbcrlf
I = I + 1
Next
Str = str & "</root>" & vbcrlf
Response. write str
%>

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.