{"id":619,"date":"2014-02-11T17:16:10","date_gmt":"2014-02-11T17:16:10","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=619"},"modified":"2022-02-03T11:25:03","modified_gmt":"2022-02-03T17:25:03","slug":"dotnet-zipfiles-hard-links-get-super-simple","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/","title":{"rendered":"ZipFiles &#8211; not that hard, but here are some links to get through what should be super simple"},"content":{"rendered":"<p>I need to zip files and add a timestamp to the zip filename, or I don&#8217;t have a backup system (I just have a copy of the latest files whether or not they are correct). <a title=\"SMO for SQL Backup \u2026 of sorts\" href=\"http:\/\/elbsolutions.com\/projects\/smo-sql-backup-sorts\/\" target=\"_blank\" rel=\"noopener noreferrer\">This is TOTALLY related to my article on scripting out my SQL table data contents<\/a>. This is run as a scheduled task &#8211; but I had to take a copy of the solution on my LOCAL drive- not a network copy or else the scheduled tasks does not work. See my article to <a title=\"Windows Task Scheduler \u2013 a consistent way to execute exe files\" href=\"http:\/\/elbsolutions.com\/projects\/windows-task-scheduler-a-consistent-way-to-execute-exe-files\/\" target=\"_blank\" rel=\"noopener noreferrer\">reduce frustrations on Scheduled Tasks<\/a>.<\/p>\n<p>Using c# &#8211; here is the code snibbet (read the whole article though)<!--more--><\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">&lt;\/pre&gt;\r\n&amp;nbsp;\r\n\r\nif ((machineName = myargs.Item(&quot;scripttables&quot;)) != null)\r\n {\r\n\r\nDateTime filenameTimeStamp = DateTime.Now;\r\n string fileTSstring = filenameTimeStamp.ToString(&quot;yyyyMMss_HHmmsstt&quot;);\r\n string startPath = Directory.GetCurrentDirectory()+@&quot;\\data&quot;;\/\/ @&quot;.&quot;;\r\n string zipPath = @&quot;tablesScripted_&quot; + db.Name + &quot;_&quot; + fileTSstring + &quot;.zip&quot;;\r\n\r\nConsole.WriteLine(&quot;Completed ONLY scripting the tables and making the archive called '&quot; + zipPath + &quot;'&quot;);\r\n System.IO.Compression.ZipFile.CreateFromDirectory(startPath, zipPath);\r\n\r\nreturn;\r\n }\r\n&lt;pre&gt;<\/pre>\n<p>Before you use this code<\/p>\n<ul>\n<li><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms404280%28v=vs.110%29.aspx\" target=\"_blank\" rel=\"noopener noreferrer\">Microsoft has an easy example<\/a>\u00a0(read note about the reference &#8211; next point below)<\/li>\n<\/ul>\n<p><a style=\"font-style: normal;\" href=\"http:\/\/forums.asp.net\/t\/1895311.aspx\" target=\"_blank\" rel=\"noopener noreferrer\">You have to reference the following TWO (2!!!!!) dlls\u00a0<\/a>and put the &#8220;using System.IO.Compression&#8221; at the top in this directory. (I did say TWO dll&#8217;s right?)<\/p>\n<ol>\n<li>~\/Windows\/Microsoft.NET\/assembly\/GAC_MSIL\/System.IO.Compression.FileSystem\/(Your .NET Version)\/System.IO.Compression.FileSystem.dll<\/li>\n<li>~\/Windows\/Microsoft.NET\/assembly\/GAC_MSIL\/System.IO.Compression\/(Your .NET Version)\/System.IO.Compression.dll<\/li>\n<\/ol>\n<ul>\n<li><a href=\"http:\/\/www.geekzilla.co.uk\/View00FF7904-B510-468C-A2C8-F859AA20581F.htm\" target=\"_blank\" rel=\"noopener noreferrer\">get the string pattern (great simple reference article) <\/a>so we have a date like year, month, date hour, minute, second<\/li>\n<li>put &#8216;er all together, shake and stir &#8211; you are done<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I need to zip files and add a timestamp to the zip filename, or I don&#8217;t have a backup system (I just have a copy of the latest files whether or not they are correct). This is TOTALLY related to my article on scripting out my SQL table data contents. This is run as a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-619","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ZipFiles - not that hard, but here are some links to get through what should be super simple - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ZipFiles - not that hard, but here are some links to get through what should be super simple - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"I need to zip files and add a timestamp to the zip filename, or I don&#8217;t have a backup system (I just have a copy of the latest files whether or not they are correct). This is TOTALLY related to my article on scripting out my SQL table data contents. This is run as a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2014-02-11T17:16:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:25:03+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/dotnet-zipfiles-hard-links-get-super-simple\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/dotnet-zipfiles-hard-links-get-super-simple\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"ZipFiles &#8211; not that hard, but here are some links to get through what should be super simple\",\"datePublished\":\"2014-02-11T17:16:10+00:00\",\"dateModified\":\"2022-02-03T17:25:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/dotnet-zipfiles-hard-links-get-super-simple\\\/\"},\"wordCount\":314,\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/dotnet-zipfiles-hard-links-get-super-simple\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/dotnet-zipfiles-hard-links-get-super-simple\\\/\",\"name\":\"ZipFiles - not that hard, but here are some links to get through what should be super simple - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2014-02-11T17:16:10+00:00\",\"dateModified\":\"2022-02-03T17:25:03+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/dotnet-zipfiles-hard-links-get-super-simple\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/dotnet-zipfiles-hard-links-get-super-simple\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/dotnet-zipfiles-hard-links-get-super-simple\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ZipFiles &#8211; not that hard, but here are some links to get through what should be super simple\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ZipFiles - not that hard, but here are some links to get through what should be super simple - ELB Solutions.com Inc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/","og_locale":"en_US","og_type":"article","og_title":"ZipFiles - not that hard, but here are some links to get through what should be super simple - ELB Solutions.com Inc.","og_description":"I need to zip files and add a timestamp to the zip filename, or I don&#8217;t have a backup system (I just have a copy of the latest files whether or not they are correct). This is TOTALLY related to my article on scripting out my SQL table data contents. This is run as a [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2014-02-11T17:16:10+00:00","article_modified_time":"2022-02-03T17:25:03+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"ZipFiles &#8211; not that hard, but here are some links to get through what should be super simple","datePublished":"2014-02-11T17:16:10+00:00","dateModified":"2022-02-03T17:25:03+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/"},"wordCount":314,"articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/","url":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/","name":"ZipFiles - not that hard, but here are some links to get through what should be super simple - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2014-02-11T17:16:10+00:00","dateModified":"2022-02-03T17:25:03+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/dotnet-zipfiles-hard-links-get-super-simple\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"ZipFiles &#8211; not that hard, but here are some links to get through what should be super simple"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=619"}],"version-history":[{"count":5,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/619\/revisions"}],"predecessor-version":[{"id":2825,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/619\/revisions\/2825"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}