<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Option Explicit %>
<% On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Server.ScriptTimeout=99999999 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文件解包程序</title>
</head>

<body>
<%
	Dim strLocalPath
	'得到当前文件夹的物理路径
	strLocalPath=Left(Request.ServerVariables("PATH_TRANSLATED"),InStrRev(Request.ServerVariables("PATH_TRANSLATED"),"\"))

	Dim objXmlFile
	Dim objNodeList
	Dim objFSO
	Dim objStream
	Dim i,j
	
	Set objXmlFile = Server.CreateObject("Microsoft.XMLDOM")
		objXmlFile.load(Server.MapPath("update.xml"))
		
		If objXmlFile.readyState=4 Then
			If objXmlFile.parseError.errorCode = 0 Then
				
				Set objNodeList = objXmlFile.documentElement.selectNodes("//folder/path")
				Set objFSO = CreateObject("Scripting.FileSystemObject")
					
					j=objNodeList.length-1
					For i=0 To j
						If objFSO.FolderExists(strLocalPath & objNodeList(i).text)=False Then
							objFSO.CreateFolder(strLocalPath & objNodeList(i).text)
						End If
						Response.Write "创建目录" & objNodeList(i).text & "<br/>"
						Response.Flush
					Next
				Set objFSO = nothing
				Set objNodeList = nothing
				Set objNodeList = objXmlFile.documentElement.selectNodes("//file/path")
				
					j=objNodeList.length-1
					For i=0 To j
						Set objStream = CreateObject("ADODB.Stream")
							With objStream
								.Type = 1
								.Open
								.Write objNodeList(i).nextSibling.nodeTypedvalue
								.SaveToFile strLocalPath & objNodeList(i).text,2
								Response.Write "释放文件" & objNodeList(i).text & "<br/>"
								Response.Flush
								.Close
							End With
						Set objStream = Nothing
					Next
				Set objNodeList = nothing
			End If
		End If
		
	Set objXmlFile = Nothing
	
response.write "文件解包完毕"
%>
</body>
</html>

