<p>FSO+递归生成文件列表(xml)</p> <p>本来生成这个xml文档是为了开发一个ftp的搜索,后来由于没有资料参考怎么搜索xml文档,也就放弃了.其中最重要的是递归的算法.生成文件列表的速度很快.这个程序可以用于生成播放列表之类的东东.需要IIS的FSO组件支持.生成类似下面的XML文档 <br /> &lt;?xml version=&quot;1.0&quot; encoding=&quot;gb2312&quot;?&gt; <br /> &lt;ftp ip=&quot;10.1.228.228&quot;&gt; <br /> &lt;DIR path=&quot;Game&quot;&gt; <br /> &lt;DIR path=&quot;仙剑奇侠传2(save)&quot;&gt; <br /> &lt;file size=&quot;346294&quot;&gt;complete_camel.rar&lt;/file&gt; <br /> &lt;file size=&quot;1886286&quot;&gt;complete_funlove.rar&lt;/file&gt; <br /> &lt;/DIR&gt; <br /> &lt;/DIR&gt; <br /> &lt;/ftp&gt;<br /> make_file_list.asp <br /> &lt;<a href="mailto:%@LANGUAGE=&quot;VBSCRIPT">%@LANGUAGE=&quot;VBSCRIPT</a>&quot; CODEPAGE=&quot;936&quot;%&gt; <br /> &lt;% <br /> '######################################' <br /> '## Copyright (C) 2003 醉雨梧桐 All rights reserved. ##' <br /> '## Powered by 醉雨梧桐 ##' <br /> '## <a href="http://btyz.51web.cn/">http://btyz.51web.cn/</a> ##' <br /> '## <a href="mailto:winterfire@163.com">winterfire@163.com</a> ##' <br /> '######################################' <br /> Dim objFo,objF,objAF,objFxml <br /> set objFo=CreateObject(&quot;Scripting.FileSystemObject&quot;) '对象<br /> set objFxml=objFo.OpenTextFile(&quot;G:\My Documents\http\Personal Works\FTP_Search\ftp.xml&quot;,2) '打开文件<br /> objFxml.WriteLine(&quot;&lt;?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;gb2312&quot;&quot;?&gt;&quot;) <br /> objFxml.WriteLine(&quot;&lt;ftp ip=&quot;&quot;10.1.228.228&quot;&quot;&gt;&quot;) <br /> Call xml_list(&quot;F:\&quot;) '开始列表 <br /> objFxml.WriteLine(&quot;&lt;/ftp&gt;&quot;) <br /> Response.Write(&quot;List is OK!) '列表成功 <br /> Function xml_list(DirName) <br /> set objFS=objFo.GetFolder(DirName) <br /> set objASD=objFS.SubFolders <br /> For Each OneDir in objASD <br /> strFdName=Trim(OneDir.Name) <br /> '下面所列的文件夹不生成在列表中(系统文件或者隐藏文件) <br /> If strFdName&lt;&gt;&quot;Config.Msi&quot; EQV strFdName&lt;&gt;&quot;RECYCLED&quot; EQV strFdName&lt;&gt;&quot;RECYCLER&quot; EQV strFdName&lt;&gt;&quot;System Volume Information&quot; Then <br /> OneDirName=xml_format(OneDir.Name) '对&amp;进行转义 <br /> objFxml.WriteLine(&quot;&lt;DIR path=&quot;&quot;&quot;&amp;OneDirName&amp;&quot;&quot;&quot;&gt;&quot;) '生成&lt;DIR path=&quot;文件夹&quot;&gt;&lt;/DIR&gt; <br /> SDirName=DirName&amp;&quot;\&quot;&amp;OneDir.Name '下一个递归的地址 <br /> Call xml_list(SDirName) '调用递归 <br /> objFxml.WriteLine(&quot;&lt;/DIR&gt;&quot;) <br /> End If '结束判断 <br /> Next <br /> set objSF=objFS.Files <br /> For Each OneFile in objSF '列出文件 <br /> objFxml.WriteLine(&quot;&lt;file size=&quot;&quot;&quot;&amp;OneFile.size&amp;&quot;&quot;&quot;&gt;&quot;&amp;OneFile.Name&amp;&quot;&lt;/file&gt;&quot;) '生成&lt;file&gt;文件名&lt;/file&gt; <br /> Next <br /> End Function<br /> '去掉XML不允许的字符 <br /> Function xml_format(strDirName) <br /> strDirName=Replace(strDirName,&quot;&amp;&quot;,&quot;&amp;&quot;) '把半角的&amp;转化为&amp; <br /> xml_format=strDirName <br /> End Function <br /> %&gt;</p>
返回顶部 留言