권장 : ASP 오류 개체에 대한 팁 vbscript에는 스크립트 통역사가 런타임 오류를 무시하고 스크립트 코드의 실행을 계속하게하는 ON ERROR 이력서 다음 문이 있습니다. 그런 다음 스크립트는 err.number 속성의 값을 확인하여 오류가 발생했는지 확인할 수 있습니다. 오류가 발생하면 0이 아닌 값이 반환됩니다. ASP 3.0에서는 오류가 발생하여 기본값으로 "돌아 가기"에 사용할 수도 있습니다.
- '================================
- '파일 1
- 'pack.asp
- 'cpathname이 변수를 변경하십시오
- 'data.xml 파일은 현재 디렉토리에서 생성됩니다.
- 'data.xml 및 파일 2 (install.asp)를 웹 루트 디렉토리로 업로드
- '설치를 실행하십시오 .ASP 포장 풀기
- '위의 두 파일을 수동으로 삭제합니다
- '================================
- <%옵션 출현%>
- <%onerrorresumenext%>
- <%
- Server.ScriptTimeout = 9999999
- DimcPathName
- DIMSTARTIME, ENDTIME
- '여기에서 포장 할 폴더로의 경로를 변경하십시오.
- cpathname = f : websymr
- startTime = 타이머 ()
- functionbianli (경로)
- DIMDOC
- Dimfso'fso 객체
- Dimobjfolder '폴더 개체
- Dimobjsubfolders의 하위 폴더 컬렉션
- Dimobjsubfolder의 하위 폴더 객체
- Dimobjfiles의 파일 수집
- Dimobjfile '파일 객체
- Dimobjstream
- DimpathName, TextStream, pp, Xfolder, Xfpath, Xfile, XPath, Xstream
- setfso = server.createobject (scripting.filesystemobject)
- setobjfolder = fso.getfolder (path) '폴더 개체 생성
- 응답 .writepath
- 응답. 플러시
- setDoc = server.createObject (msxml2.dodocument)
- doc.loadserver.mappath (data.xml)
- doc.async = false
- '각 폴더 경로에 쓰십시오
- setxfolder = doc.selectsinglenode (// z-blog) .appendChild (doc.createElement (폴더))
- setxfpath = xfolder.appendChild (Doc.CreateElement (Path))
- xfpath.text = replace (path, cpathname,)
- setobjfiles = objfolder.files
- foreachobjfileinobjfiles
- 응답. 쓰기
- ---
- pp = path && objfile.name
- 응답 .Writep &
- 응답. 플러시
- '================================================================================
- '파일의 경로와 파일 내용
- setxfile = doc.selectsinglenode (// z-blog) .appendChild (doc.createElement (파일))
- setxpath = xfile.appendChild (Doc.CreateElement (Path))
- xpath.text = replace (pp, cpathname,)
- '파일 컨텐츠를 읽고 XML 파일에 쓰기 위해 파일 스트림을 만듭니다.
- setobjstream = server.createobject (adodb.stream)
- objstream.type = 1
- objstream.open ()
- objstream.loadfromfile (pp)
- objstream.position = 0
- setxstream = xfile.appendChild (doc.createElement (stream))
- xstream.setattributexmlns : dt, urn : schemas-microsoft-com : 데이터 타입
- '파일 내용은 2 시스템에 저장됩니다
- xstream.datatype = bin.base64
- xstream.nodetypedValue = objstream.read ()
- setobjstream = 아무것도
- setxpath = 아무것도 없습니다
- setxstream = 아무것도
- setxfile = 아무것도
- '================================================================================
- 다음
- 응답 <p>
- doc.saveserver.mappath (data.xml)
- setxfpath = 아무것도
- setxfolder = 아무것도 없습니다
- setDoc = 아무것도
- '생성 된 하위 폴더 객체
- setobjsubfolders = objfolder.subfolders
- '호출은 재귀 적으로 하위 폴더를 가로 지른다
- foreachobjsubfolderinobjsubfolders
- PathPathName = Path ++ objsubfolder.name
- Bianli (Pathname)
- 다음
- setobjfolder = 아무것도 없습니다
- setobjsubfolders = 아무것도
- setfso = 아무것도
- 최종 기능 장애
- Dimdoc, objpi
- '빈 XML 파일을 만들려면 파일에 쓸 준비를합니다.
- setDoc = server.createObject (msxml2.dodocument)
- doc.async = false
- setobjpi = doc.CreateProcessingInstruction (XML, version = '1.0'Encoding ='utf-8 ')
- doc.insertbeforeobjpi, doc.childnodes (0)
- Doc.AppendChild (Doc.CreateElement (Z-Blog))
- doc.saveserver.mappath (data.xml)
- setobjpi = 아무것도
- setDoc = 아무것도
- Bianli (cpathname)
- endtime = timer ()
- %>
- 페이지 실행 시간 : <%= FormatNumber ((endtime-startime), 3)%> 초
- '=============================================
- '파일 2
- 'install.asp
- '이 파일은 z- 블로그 설치 파일에서 변경되었습니다
- '=============================================
- <%@codepage = 65001%>
- <%옵션 출현%>
- <%onerrorresumenext%>
- <%response.charset = utf-8%>
- <html>
- <헤드>
- <title> 파일 포장 풀기 프로그램 </title>
- </head>
- <body>
- <textarename = contentcols = 90rows = 20Style = 경계 : 0px; 오버플로 : 오버 플로 : Auto; Border-Width : 0px; 너비 : 100%; 배경 색 :#e8f3ff; 스크롤 = 자동>
- <%
- DIMSTRLOCALPATH
- '현재 폴더에 대한 물리적 경로를 얻으십시오
- strlocalpath = left (request.servervariables (path_translated), instrev (request.servervariables (path_translated),))
- dimstrdbpath
- dimobjxmlfile
- Dimobjnodelist
- Dimobjfso
- Dimobjstream
- 디미, j
- setobjxmlfile = server.createobject (microsoft.xmldom)
- objxmlfile.load (server.mappath (data.xml))
- ifobjxmlfile.readystate = 4then
- ifobjxmlfile.parseerror.errorcode = 0then
- setobjnodelist = objxmlfile.documentelement.selectnodes (// 폴더/Path)
- setobjfso = createobject (scripting.filesystemobject)
- j = objnodelist.length-1
- fori = 0toj
- ifobjfso.dolerexists (strlocalpath & objnodelist (i) .text) = falsethen
- objfso.createfolder (strlocalpath & objnodelist (i) .text)
- endif
- response.writecreate directory & objnodelist (i) .text & vbcrlf
- 응답. 플러시
- 다음
- setobjnodelist = objxmlfile.documentelement.selectnodes (// file/path)
- j = objnodelist.length-1
- fori = 0toj
- setobjstream = createobject (adodb.stream)
- bjstream없이
- .type = 1
- .열려 있는
- .writeobjnodelist (i) .nextsibling.nodetypedValue
- .savetofilestrlocalpath & objnodelist (i) .text, 2
- 응답. 릴리스 파일 및 objnodelist (i) .text & vbcrlf
- 응답. 플러시
- .닫다
- 끝
- setobjstream = 아무것도
- 다음
- endif
- endif
- %>
- </textarea>
- <%response.write <Script> Alert ( '파일 포장되지 않은 완료!'); </script>%>
공유 : ASP 개발에서 유용한 기능 모음 (1) ASP 개발에서 유용한 기능 모음이 매우 유용합니다! 나는 모두가 그것을 유지하기를 바랍니다! % '****************************************************** 'Prevent external submission'*************************************** function ChkPost() dim server_v1,server_v2 chkpost=false server_v1=Cstr(Request.ServerVari