以下是读取指定文件夹的所有文件(不包括子文件夹)的asp代码,返回的是xml便于和flex交互
'创建一个FileSystemObject对象的事例 Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject") '创建一个Folder对象 foldername=server.mappath("服务器下文件夹./") Set MyFolder=MyFileObject.GetFolder(foldername)
str="<?xml version='1.0' encoding='utf-8'?>"& vbcrlf & "<root>" & vbcrlf '先放入两个原始数据,防止只有一条记录与flex交互有bug产生(前提是文件夹中至少有一条记录,不然仍然有bug) 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 '循环显示其中文件 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 %>