fso+ recursively generate file list (XML)

Source: Internet
Author: User
Tags file size ftp rar
fso|xml| recursion


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= "Chinese Paladin 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 OneD The folders listed under IR in OBJASD
Strfdname=trim (onedir.name)
are not generated in the list (System files or hidden files)
If strfdname<> "Config.msi" EQV strfdname<> "Recycled" EQV strfdname<> "RECYCLER" EQV strfdname<> "System Volume Information" Then br> Onedirname=xml_format (onedir.name) ' & Escape
Objfxml.writeline ("<dir path=" "&OneDirName&" "" > "" Generates <dir path= "folder" ></DIR>
sdirname=dirname& "\ &onedir.name ' next recursive address
call Xml_ List (sdirname) ' calls recursive
Objfxml.writeline (' </DIR> ')
End If ' ending judgment
Next
Set objsf=objfs.files
Fo R each onefile in OBJSF ' list files
objfxml.writeline ("<file size=" "&OneFile.size&" ">" &onefile.name & "</file>") ' Generate <file> filename </file>
Next
End Function

' Remove characters that are not allowed by XML
Function Xml_format (strDirName)
Strdirname=replace (strDirName, "&", "&") ' Convert Half-corner & to &
Xml_format=strdirname
End Function
%>




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.