|
- <?xml version="1.0" encoding="gb2312"?>
- <ftp ip="10.1.228.228">
- <DIR path="Game">
- <DIR path="久久网络(save)">
- <file size="346294">complete_camel.rar</file>
- <file size="1886286">complete_funlove.rar</file>
- </DIR>
- </DIR>
- </ftp>
- 以上为要生成的.xml文件,下面为make_file_list.asp文件,里面参考代码为:
- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
- <%
- '######################################'
- '## Copyright (C) 2003 醉雨梧桐 All rights reserved. ##'
- '## Powered by 醉雨梧桐 ##'
- '## http://btyz.51web.cn/ ##'
- '## winterfire@163.com ##'
- '######################################'
- Dim objFo,objF,objAF,objFxml
- set objFo=CreateObject("Scripting.FileSystemObject") '对象
- set objFxml=objFo.OpenTextFile("G:\My Documents\http\Personal Works\FTP_Search\ftp.xml",2) '打开文件
- objFxml.WriteLine("<?xml version=""1.0"" encoding=""gb2312""?>")
- objFxml.WriteLine("<ftp ip=""10.1.228.228"">")
- Call xml_list("F:") '开始列表
- objFxml.WriteLine("</ftp>")
- Response.Write("List is OK!) '列表成功
- Function xml_list(DirName)
- set objFS=objFo.GetFolder(DirName)
- set objASD=objFS.SubFolders
- For Each OneDir in objASD
- strFdName=Trim(OneDir.Name)
- '下面所列的文件夹不生成在列表中(系统文件或者隐藏文件)
- If strFdName<>"Config.Msi" EQV strFdName<>"RECYCLED" EQV strFdName<>"RECYCLER" EQV strFdName<>"System Volume Information" Then
- OneDirName=xml_format(OneDir.Name) '对&进行转义
- objFxml.WriteLine("<DIR path="""&OneDirName&""">") '生成<DIR path="文件夹"></DIR>
- SDirName=DirName&""&OneDir.Name '下一个递归的地址
- Call xml_list(SDirName) '调用递归
- objFxml.WriteLine("</DIR>")
- End If '结束判断
- Next
- set objSF=objFS.Files
- For Each OneFile in objSF '列出文件
- objFxml.WriteLine("<file size="""&OneFile.size&""">"&OneFile.Name&"</file>") '生成<file>文件名</file>
- Next
- End Function
- '去掉XML不允许的字符
- Function xml_format(strDirName)
- strDirName=Replace(strDirName,"&","&") '把半角的&转化为&
- xml_format=strDirName
- End Function
- %
复制代码 |
本文地址: https://jiufei.net/bbs/thread-1493-1-1.html
|