ASP in the FSO recursively generate file list (XML)

Source: Internet
Author: User
Tags file size ftp rar

This XML document was originally generated to develop an FTP search, and later because there was no data reference to how to search for XML documents, and give up. The most important of these is the recursive algorithm. The file list is generated quickly. This program can be used to generate playlists and things like that. Require the FSO component support for IIS. Generate an XML document similar to the following

<?xml version="1.0" encoding="gb2312"?>
<ftp ip="10.1.228.228">
<DIR path="Game">
<DIR path="仙剑奇侠传2(save)">
<file size="346294">complete_camel.rar</file>
<file size="1886286">complete_funlove.rar</file>
</DIR>
</DIR>
</ftp>

Make_file_list.asp

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
'######################################'
' # # Copyright (C) 2003 Drunk Rain Indus All rights reserved. ##'
' # # Powered by Drunk Rain Indus # '
' # # http://btyz.51web.cn/# #
' # # winterfire@163.com # #
'######################################'
Dim Objfo,objf,objaf,objfxml
Set Objfo=createobject ("Scripting.FileSystemObject") ' Object
Set Objfxml=objfo.opentextfile ("G:\My documents\http\personal works\ftp_search\ftp.xml", 2) ' Open file
Objfxml.writeline ("<?xml version=" "1.0" "encoding=" "gb2312" "?>")
Objfxml.writeline ("<ftp ip=" "10.1.228.228" ">")
Call Xml_list ("f:\") ' Start list
Objfxml.writeline ("</ftp>")
Response.Write ("List is ok!") List successful
Function xml_list (dirname)
Set Objfs=objfo.getfolder (dirname)
Set Objasd=objfs.subfolders
For each onedir in OBJASD
Strfdname=trim (Onedir.name)
' The folders listed below are not generated in the list (System files or hidden files)
If strfdname<> "Config.msi" EQV strfdname<> "recycled" EQV strfdname<> "RECYCLER" EQV > "System Volume Information" Then
Onedirname=xml_format (Onedir.name) ' Escapes &
Objfxml.writeline ("<dir path=" "&OneDirName&" ">") ' Generate <dir path= folder ' ></DIR>
sdirname=dirname& "\" &onedir.name ' next recursive address
Call Xml_list (sdirname) ' calls recursion
Objfxml.writeline ("</DIR>")
End If ' Ending judgment
Next
Set Objsf=objfs.files
For each onefile in OBJSF ' list files
Objfxml.writeline ("<file size=" "&OneFile.size&" ">" &OneFile.Name& "</file>") ' Generate < file> file name </file>
Next
End Function
' Remove characters that are not allowed by XML
Function Xml_format (strDirName)
Strdirname=replace (strDirName, "&", "&amp;") ' Convert the & of Half-width to &amp;
Xml_format=strdirname
End Function
%>

Related Article

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.