{"id":41,"date":"2007-07-13T02:04:27","date_gmt":"2007-07-13T02:04:27","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?page_id=41"},"modified":"2008-01-18T16:28:26","modified_gmt":"2008-01-18T16:28:26","slug":"function-archivehomedir","status":"publish","type":"page","link":"https:\/\/www.wapshere.com\/missmiis\/code-snippets\/function-archivehomedir","title":{"rendered":"NWHomeDir_CSExtension.vb: Function ArchiveHomeDir"},"content":{"rendered":"<p><font size=\"1\" color=\"#0000ff\"><font size=\"1\" color=\"#0000ff\">Imports<font size=\"1\"><font color=\"#000000\"> <a target=\"_blank\" href=\"http:\/\/www.zbitinc.com\/product.aspx?p=1\">zbitz<\/a><\/font><\/font><\/font><\/font><font size=\"1\" color=\"#0000ff\"><font size=\"1\" color=\"#0000ff\"> <\/font><\/font><\/p>\n<p><font size=\"1\" color=\"#0000ff\">Private<\/font><font size=\"1\"> <\/font><font size=\"1\" color=\"#0000ff\">Function<\/font><font size=\"1\"> ArchiveHomeDir(<\/font><font size=\"1\" color=\"#0000ff\">ByVal<\/font><font size=\"1\"> path <\/font><font size=\"1\" color=\"#0000ff\">As<\/font><font size=\"1\"> <\/font><font size=\"1\" color=\"#0000ff\">String<\/font><font size=\"1\">) <\/font><font size=\"1\" color=\"#0000ff\">As<\/font><font size=\"1\"> Int16<\/font><br \/>\n<font size=\"1\"><font size=\"1\" color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim<\/font><font size=\"1\"> status <\/font><font size=\"1\" color=\"#0000ff\">As<\/font><font size=\"1\"> Int16<\/font><\/font><br \/>\n<font size=\"1\"><font size=\"1\" color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim<\/font><font size=\"1\"> archive <\/font><font size=\"1\" color=\"#0000ff\">As<\/font><font size=\"1\"> <\/font><font size=\"1\" color=\"#0000ff\">New<\/font><font size=\"1\"> Czzip<\/font><\/font><font size=\"1\"> <\/font><br \/>\n<font size=\"1\"><font size=\"1\"><font color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim<\/font> archivePath <font color=\"#0000ff\">As<\/font> <font color=\"#0000ff\">String<\/font> = &#8220;\\\\&#8221; &amp; path.Split(&#8220;\\&#8221;)(2) &amp; &#8220;\\&#8221; &amp; path.Split(&#8220;\\&#8221;)(3) &amp; &#8220;\\&#8221; &amp; &#8220;ARCHIVE\\&#8221; &amp; path.Split(&#8220;\\&#8221;)(5) &amp; &#8220;.zip&#8221;<\/font><\/font><\/p>\n<p><font size=\"1\"><font size=\"1\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 <font color=\"#0000ff\">If<\/font> System.IO.File.Exists(archivePath) <font color=\"#0000ff\">Then<\/font><\/font><\/font><font size=\"1\"> <\/font><br \/>\n<font size=\"1\"><font size=\"1\"><font color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Throw<\/font> <font color=\"#0000ff\">New<\/font> UnexpectedDataException(&#8220;Archive file &#8221; &amp; archivePath &amp; &#8221; already exists&#8221;)<\/font><\/font><br \/>\n<font size=\"1\"><font size=\"1\"><font color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 End<\/font> <font color=\"#0000ff\">If<\/font><\/font><\/font><\/p>\n<p><font size=\"1\"><font size=\"1\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim logtxt = <\/font><font size=\"1\" color=\"#0000ff\">Date<\/font><font size=\"1\">.Now &amp; &#8221; Zipping &#8221; &amp; path &amp; &#8220;: &#8220;<\/font><br \/>\n<\/font><font size=\"1\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 status = archive.ZipFile(path, archivePath)<\/font><br \/>\n<font size=\"1\"><font color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 If<\/font> status = 0 <font color=\"#0000ff\">Then<\/font> <font color=\"#008000\">&#8216;Confirm zip file exists<\/font><\/font><br \/>\n<font size=\"1\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 logFile.WriteLine(logtxt &amp; &#8220;Success&#8221;)<\/font><br \/>\n<font size=\"1\"><font color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 If<\/font> <font color=\"#0000ff\">Not<\/font> System.IO.File.Exists(archivePath) <font color=\"#0000ff\">Then<\/font><\/font><br \/>\n<font size=\"1\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 status = -1<\/font><font size=\"1\"><font color=\"#0000ff\"> <\/font><\/font><br \/>\n<font size=\"1\"><font color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 End<\/font> <font color=\"#0000ff\">If<\/font><\/font><br \/>\n<font size=\"1\" color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0 Else<\/font><br \/>\n<font size=\"1\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 logFile.WriteLine(logtxt &amp; &#8220;Failed with error &#8221; &amp; status &amp; &#8220;, &#8221; &amp; archive.LastMsg)<\/font><br \/>\n<font size=\"1\"><font color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 End<\/font> <font color=\"#0000ff\">If<\/font><\/font><\/p>\n<p><font size=\"1\"><font color=\"#0000ff\">\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Return<\/font> status<\/font><\/p>\n<p><font size=\"1\"><font color=\"#0000ff\">End<\/font> <font color=\"#0000ff\">Function<\/font><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imports zbitz Private Function ArchiveHomeDir(ByVal path As String) As Int16 \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim status As Int16 \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim archive As New Czzip \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim archivePath As String = &#8220;\\\\&#8221; &amp; path.Split(&#8220;\\&#8221;)(2) &amp; &#8220;\\&#8221; &amp; path.Split(&#8220;\\&#8221;)(3) &amp; &#8220;\\&#8221; &amp; &#8220;ARCHIVE\\&#8221; &amp; path.Split(&#8220;\\&#8221;)(5) &amp; &#8220;.zip&#8221; \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 If System.IO.File.Exists(archivePath) Then \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Throw New UnexpectedDataException(&#8220;Archive file &#8221; &amp; archivePath &amp;&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":30,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-41","page","type-page","status-publish","hentry"],"jetpack_shortlink":"https:\/\/wp.me\/Pkp1o-F","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/pages\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":0,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/pages\/41\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/pages\/30"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}