加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

asp源码打包为xml的工具

发布时间:2023-07-19 13:36:21 所属栏目:Asp教程 来源:
导读:下边这个存为Pack.asp,打包文件时运行代码如下:<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <%OptionExplicit%> <%OnErrorResumeNext%> <% Response.Charset="UTF-8"%> <% Server.ScriptTimeout=99999999%> <!DOCTYP

下边这个存为Pack.asp,打包文件时运行

代码如下:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> 

<%OptionExplicit%> 

<%OnErrorResumeNext%> 

<% Response.Charset="UTF-8"%> 

<% Server.ScriptTimeout=99999999%> 

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<htmlxmlns="http://www.w3.org/1999/xhtml"> 

<head> 

<metahttp-equiv="Content-Type"content="text/html; charset=utf-8"/> 

<title>文件打包程序</title> 

</head> 

<body> 

<% 

Dim ZipPathDir, ZipPathFile 

Dim startime, endtime 

'在此更改要打包文件夹的路径 

ZipPathDir ="F:/www.yongfa365.com"' 

ZipPathFile ="update.xml" 

If Right(ZipPathDir,1)<>"/"Then ZipPathDir = ZipPathDir&"/" 

'开始打包 

CreateXml(ZipPathFile) 

'遍历目录内的所有文件以及文件夹 

Sub LoadData(DirPath) 

Dim XmlDoc 

    Dim fso 'fso对象 

Dim objFolder '文件夹对象 

Dim objSubFolders '子文件夹集合 

Dim objSubFolder '子文件夹对象 

Dim objFiles '文件集合 

Dim objFile '文件对象 

Dim objStream 

    Dim pathname, TextStream, pp, Xfolder, Xfpath, Xfile, Xpath, Xstream 

    Dim PathNameStr 

    response.Write("=========="&DirPath&"==========<br>") 

Set fso = server.CreateObject("scripting.filesystemobject") 

Set objFolder = fso.GetFolder(DirPath)'创建文件夹对象 

    Response.Write DirPath 

    Response.flush 

    Set XmlDoc = Server.CreateObject("Microsoft.XMLDOM") 

    XmlDoc.load Server.MapPath(ZipPathFile) 

    XmlDoc.async =False 

'写入每个文件夹路径 

Set Xfolder = XmlDoc.SelectSingleNode("//root").AppendChild(XmlDoc.CreateElement("folder")) 

Set Xfpath = Xfolder.AppendChild(XmlDoc.CreateElement("path")) 

    Xfpath.text = Replace(DirPath, ZipPathDir,"") 

Set objFiles = objFolder.Files 

    ForEach objFile in objFiles 

        If LCase(DirPath & objFile.Name)<> LCase(Request.ServerVariables("PATH_TRANSLATED"))Then 

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章