{"id":4975,"date":"2019-05-12T07:13:41","date_gmt":"2019-05-11T23:13:41","guid":{"rendered":"https:\/\/unitycoder.com\/blog\/?p=4975"},"modified":"2019-05-12T07:13:49","modified_gmt":"2019-05-11T23:13:49","slug":"using-sharpcompress-in-unity","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2019\/05\/12\/using-sharpcompress-in-unity\/","title":{"rendered":"Using SharpCompress in Unity"},"content":{"rendered":"\n<p>If you need to work with zip\/rar\/tar\/gzip packages, can use SharpCompress to handle opening or creating those files.<\/p>\n\n\n\n<p><strong>Compile SharpCompress DLL<\/strong> (unless you can find it online somewhere)<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Download project <a href=\"https:\/\/github.com\/adamhathcock\/sharpcompress\">https:\/\/github.com\/adamhathcock\/sharpcompress<\/a><\/li><li>Unzip and open in VisualStudio (i used 2017)<\/li><li>Security warning, press ok<\/li><li>Security warning, press ok<\/li><li>View \/ Solution Explorer .. (if not already visible)<\/li><li>Right click over SharpCompress, select Build<\/li><li>Now you should have the dll in ..\\sharpcompress-master\\sharpcompress-master\\src\\SharpCompress\\bin\\Debug\\ folder (3.5 and 4.5 versions, pick which one you like, recent unity versions support 4.5 by default, so lets pick &#8220;net45\\SharpCompress.dll&#8221;)<\/li><li>Copy it to your unity project, under Assets\\Plugins\\SharpCompress\\ SharpCompress.dll<\/li><li>If you are using Unity 2017.x or lower, go to Player Settings \/ Other settings, and enable 4.6 from &#8220;Scripting Runtime Version&#8221;<\/li><li>Test creating zip package with the script below (adjust source and output folders in the script)<\/li><\/ul>\n\n\n\n<p><strong>Source:<\/strong><br><a href=\"https:\/\/gist.github.com\/unitycoder\/edfc22570e93db61f83d582c98c4dff5\">https:\/\/gist.github.com\/unitycoder\/edfc22570e93db61f83d582c98c4dff5<\/a><\/p>\n\n\n\n<p><strong>TroubleShooting<\/strong><\/p>\n\n\n\n<p>Error in Android build:<br>&#8220;NotSupportedException: ..il2cpp\\libil2cpp\\icalls\\mscorlib\\System.Reflection.Emit\\DynamicMethod.cpp(19) : Unsupported internal call for IL2CPP:DynamicMethod::create_dynamic_method &#8211; System.Reflection.Emit is not supported.<br> 05-12 01:52:09.319  2523  2549 E Unity   :   at System.Reflection.Emit.DynamicMethod.CreateDynMethod ()&#8221;<br><br>Solution:<br>Use Mono as Scripting Backend (IL2CPP gives that error)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"423\" data-attachment-id=\"4978\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2019\/05\/12\/using-sharpcompress-in-unity\/unity-sharpcompress-create-zip\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/05\/unity-sharpcompress-create-zip.png?fit=651%2C423&amp;ssl=1\" data-orig-size=\"651,423\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"unity-sharpcompress-create-zip\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/05\/unity-sharpcompress-create-zip.png?fit=300%2C195&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/05\/unity-sharpcompress-create-zip.png?fit=651%2C423&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/05\/unity-sharpcompress-create-zip.png?resize=651%2C423&#038;ssl=1\" alt=\"\" class=\"wp-image-4978\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/05\/unity-sharpcompress-create-zip.png?w=651&amp;ssl=1 651w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/05\/unity-sharpcompress-create-zip.png?resize=300%2C195&amp;ssl=1 300w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>If you need to work with zip\/rar\/tar\/gzip packages, can use SharpCompress to handle opening or creating those files. Compile SharpCompress DLL (unless you can find it online somewhere) Download project https:\/\/github.com\/adamhathcock\/sharpcompress Unzip and open in VisualStudio (i used 2017) Security warning, press ok Security warning, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4978,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[804,1,3],"tags":[840,1093,1094,1092],"class_list":["post-4975","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripts","category-uncategorized","category-unity3d","tag-dll","tag-rar","tag-sharpcompress","tag-zip"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2019\/05\/unity-sharpcompress-create-zip.png?fit=651%2C423&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-1if","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=4975"}],"version-history":[{"count":3,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4975\/revisions"}],"predecessor-version":[{"id":4979,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4975\/revisions\/4979"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/4978"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=4975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=4975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=4975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}