asp源碼打包成xml的工具
2024-05-04 11:00:42
供稿:網友
下邊這個存為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("http://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