VisualStudio2010开发C#资源文件中导入zip并释放

2014年01月17日 其他资源 17条评论 阅读10901次

VisualStudio2010开发C#资源文件中导入zip并释放

 

项目中要用到一个 zip 文件,在需要的时候进行解压。

 

之前最初的做法是把该 zip 文件放置到和 exe 同一目录下,需要时,先判断该 zip 文件存在否,若存在,则进行解压利用之。

 

项目做到最后,考虑到用户有可能会改动这个 zip 文件,所以想改善一下这个地方。

 

要解决这个问题,很容易想到了把这个 zip 文件不呈现给用户,让用户看不见,也就没有操作、改动源文件的机会了。

 

C# 开发中,大家都知道有个名叫做 “Resources” 的资源文件夹,一般最常规的来说,应用程序用到的图片会作为资源放置到这个专用的文件夹中。这样来, zip 文件应该也是可以当做应用程序资源来放到 “Resources” 资源文件夹的。

 

在 VisualStudio 的资源管理中,加入一个存在的文件,选择要导入的 zip 文件

 

在要使用该 zip 文件的地方直接从资源管理类中取得 byte[] 。

 

byte[] zipfile = (byte[])Properties.Resources.ResourceManager.GetObject("zip_file_name");

 

File.WriteAllBytes(filename, zipfile);

 

仅需要上面两行代码,就可以实现把资源文件中导入的 zip 文件重新写入到磁盘上

 

用完 zip 文件,便可执行文件删除操作。

 

这样就不用担心用户会修改 zip 源文件带来的潜在问题了。

 

到此。。。。2014年1月17日记录。

分享本文至:

WRITTEN BY

avatar
本文标签:C#
看了本文是不是觉得很赞,那就赶紧点击下面按钮分享给身边的朋友吧!

17 条评论

  1. <a href="http://www.matkailuvarkaus.net/air-jordan-eclipse-p%C3%BArpura-rojo-kurpese">air jordan eclipse p煤rpura rojo</a> <a href="http://www.medmanage.net/nike-hyperrev-2015-wolf-gris-azul-obuva">nike hyperrev 2015 wolf gris azul</a> <a href="http://www.medsample.net/adidas-nitrocharge-footbtutti-marrone-verde-obuvf">adidas nitrocharge footbtutti marrone verde</a> <a href="http://www.metacommunities.net/nike-air-max-95-bianca-and-rosso-obuvf">nike air max 95 bianca and rosso</a> <a href="http://www.metalinquisition.net/adizero-f50-schwarz-wei%C3%9F-rot-schuhef">adizero f50 schwarz wei脽 rot</a> <a href="http://www.michigangolfguide.net/asics-gel-kayano-21-p%C3%BArpura-negro-kurpesd">asics gel kayano 21 p煤rpura negro</a>
    airdirectairways http://www.airdirectairways.net/

  2. <a href="http://www.qtnkxrcr.com/nike-free-runs-5.0-nero-and-neon-verde-scarpei">nike free runs 5.0 nero and neon verde</a> <a href="http://www.blcatering.com/jacksonville-jaguars-new-era-2018-nfl-training-39thirty-cap-hath">jacksonville jaguars new era 2018 nfl training 39thirty cap</a> <a href="http://www.uchbhekf.com/hommes-nike-lebron-12-light-gris-vert-chaussuresh">hommes nike lebron 12 light gris vert</a> <a href="http://www.recspokane.com/adidas-stan-smith-jaune-vert-chaussuresj">adidas stan smith jaune vert</a> <a href="http://www.sjgncnph.com/nike-cortez-nylon-m%C3%A4nner-glowing-star-blau-wei%C3%9F-schuhek">nike cortez nylon m盲nner glowing star blau wei脽</a> <a href="http://www.loewendoors.com/usa-jersey-kyrie-irving-nflh">usa jersey kyrie irving</a>
    sozoteki http://www.sozoteki.com/

  3. <a href="http://www.fleetboilers.com/nike-free-flyknit-3.0-ladies-fonctionnement-chaussures-jordan-kurpesc">nike free flyknit 3.0 ladies fonctionnement chaussures jordan</a> <a href="http://www.jettstreaminc.com/air-jordan-ultra-fly-plata-blanco-scarpec">air jordan ultra fly plata blanco</a> <a href="http://www.maverickviral.com/hombres-nike-flyknit-lunar-2-azul-gris-schuhed">hombres nike flyknit lunar 2 azul gris</a> <a href="http://www.iubhlis.com/nike-air-max-90-sneakerboot-gr%C3%A5-guld-obuvf">nike air max 90 sneakerboot gr氓 guld</a> <a href="http://www.djterryhunter.com/nike-air-huarache-or-leaf-vert-butya">nike air huarache or leaf vert</a> <a href="http://www.msdarby.com/nike-huarache-free-mid-marinen-butya">nike huarache free mid marinen</a>
    mpdcir http://www.mpdcir.com/

  4. <a href="http://www.lvnailbar.com/adidas-gazelle-light-violet-chaussuresj">adidas gazelle light violet</a> <a href="http://www.eisenhards.com/air-jordan-retro-1-low-grau-wei%C3%9F-schwarz-schuhek">air jordan retro 1 low grau wei脽 schwarz</a> <a href="http://www.martinmakeup.com/dwyane-wade-in-bulls-jersey-nflh">dwyane wade in bulls jersey</a> <a href="http://www.dgrabovsky.com/kvinner-nike-air-max-90-prem-tape-sn-menn-gr%C3%B8nn-svart-obuvi">kvinner nike air max 90 prem tape sn menn gr酶nn svart</a> <a href="http://www.madeinmyindia.com/zapatillas-adidas-predator-shoesj">zapatillas adidas predator</a> <a href="http://www.manglammovers.com/nike-air-max-90-hyperfuse-grey-red-shoesl">nike air max 90 hyperfuse grey red</a>
    forttr http://www.forttr.com/

  5. <a href="http://www.khalataxi.com/nike-air-max-2017-kpu-ii-svart-s%C3%B8lv-chaussuresa">nike air max 2017 kpu ii svart s酶lv</a> <a href="http://www.miaclearbras.com/nike-new-england-patriots-70-logan-mankins-elite-navy-blue-team-color-jersey-nflc">nike new england patriots 70 logan mankins elite navy blue team color jersey</a> <a href="http://www.divyangbazar.com/black-and-white-air-max-1-runningg">black and white air max 1</a> <a href="http://www.dixiepundit.com/zdeno-chara-33-boston-bruins-reebok-premier-alternate-jersey-small-nflv">zdeno chara 33 boston bruins reebok premier alternate jersey small</a> <a href="http://www.ifshaildamage.com/nike-lebron-witness-grey-orange-trainersa">nike lebron witness grey orange</a> <a href="http://www.nanterrelec.com/nike-free-5.0-svart-and-s%C3%B8lv-scarpec">nike free 5.0 svart and s酶lv</a>
    seemyvcard http://www.seemyvcard.com/

  6. <a href="http://www.injost.com/zdeno-chara-33-boston-bruins-reebok-premier-alternate-jersey-small-nflv">zdeno chara 33 boston bruins reebok premier alternate jersey small</a> <a href="http://www.wonjuvally.com/nike-huarache-black-desert-camo-trainersa">nike huarache black desert camo</a> <a href="http://www.carrollgrp.com/air-jordan-3-wei%C3%9F-metalleic-silber-hair-scarpec">air jordan 3 wei脽 metalleic silber hair</a> <a href="http://www.nrastogi.com/drake-p%C3%BArpura-jordan-5-kurpesc">drake p煤rpura jordan 5</a> <a href="http://www.annersroofing.com/ray-ban-sunglasses-rb2151-wayfarer-square-yard-sunglassesg">ray ban sunglasses rb2151 wayfarer square yard</a> <a href="http://www.orderollie.com/game-womens-julien-davenport-red-alternate-jersey-nfl-nike-houston-texans-70-nflr">game womens julien davenport red alternate jersey nfl nike houston texans 70</a>
    hanayaflowers http://www.hanayaflowers.com/

  7. avatar divyangbazar

    <a href="http://www.cremontana.com/air-jordan-10-ovo-jordan-3-trainersa">air jordan 10 ovo jordan 3</a> <a href="http://www.holeninegolf.com/nike-zoom-pegasus-34-femminile-argento-cielo-blu-scarpec">nike zoom pegasus 34 femminile argento cielo blu</a> <a href="http://www.boobseze.com/nike-roshe-run-gr%C3%BCn-palm-tree-kurpesd">nike roshe run gr眉n palm tree</a> <a href="http://www.divyangshop.com/macy-s-oakley-sunglasses-asian-frame-sunglassesg">macy s oakley sunglasses asian frame</a> <a href="http://www.caveduperreux.com/logan-woodside-cincinnati-bengals-youth-game-nike-jersey-white-nflr">logan woodside cincinnati bengals youth game nike jersey white</a> <a href="http://www.fabloomsilk.com/barato-asics-gel-noosa-tri-7-mujeres-rojo-skoa">barato asics gel noosa tri 7 mujeres rojo</a>
    divyangbazar http://www.divyangbazar.com/

  8. avatar kifftradingco

    <a href="http://www.ictbel.com/kobe-8-lyser%C3%B8d-sort-obuvc">kobe 8 lyser酶d sort</a> <a href="http://www.ioioland.com/limited-womens-joel-heath-navy-blue-jersey-nfl-nike-houston-texans-93-therma-long-sleeve-nflw">limited womens joel heath navy blue jersey nfl nike houston texans 93 therma long sleeve</a> <a href="http://www.sesliesenyurt.com/2014-15-chelsea-fc-26-terry-home-soccer-shirt-kit-nflv">2014 15 chelsea fc 26 terry home soccer shirt kit</a> <a href="http://www.wethinkjerky.com/air-max-griffey-2013-skog">air max griffey 2013</a> <a href="http://www.dadees.com/billig-nike-huarache-high-herre-gul-skob">billig nike huarache high herre gul</a> <a href="http://www.pickwickcrc.com/cool-nfl-knit-hats-download-hatd">cool nfl knit hats download</a>
    kifftradingco http://www.kifftradingco.com/

  9. avatar ezzolawaz

    <a href="http://www.ictbel.com/kobe-8-lyser%C3%B8d-sort-obuvc">kobe 8 lyser酶d sort</a> <a href="http://www.ioioland.com/limited-womens-joel-heath-navy-blue-jersey-nfl-nike-houston-texans-93-therma-long-sleeve-nflw">limited womens joel heath navy blue jersey nfl nike houston texans 93 therma long sleeve</a> <a href="http://www.sesliesenyurt.com/2014-15-chelsea-fc-26-terry-home-soccer-shirt-kit-nflv">2014 15 chelsea fc 26 terry home soccer shirt kit</a> <a href="http://www.wethinkjerky.com/air-max-griffey-2013-skog">air max griffey 2013</a> <a href="http://www.dadees.com/billig-nike-huarache-high-herre-gul-skob">billig nike huarache high herre gul</a> <a href="http://www.pickwickcrc.com/cool-nfl-knit-hats-download-hatd">cool nfl knit hats download</a>
    ezzolawaz http://www.ezzolawaz.com/

  10. avatar glplawyers

    <a href="http://www.ictbel.com/nike-flyknit-lunar-1-rose-martini-scarpeb">nike flyknit lunar 1 rose martini</a> <a href="http://www.ioioland.com/nike-air-max-95-green-spain-shoeso">nike air max 95 green spain</a> <a href="http://www.sesliesenyurt.com/air-jordan-retro-4-himmelblau-gr%C3%BCn-kurpesb">air jordan retro 4 himmelblau gr眉n</a> <a href="http://www.wethinkjerky.com/nike-shop-fussballschuhe-nike-mercurial-superfly-fg-fest-zapatost">nike shop fussballschuhe nike mercurial superfly fg fest</a> <a href="http://www.dadees.com/custom-painted-converse-uk-shoesz">custom painted converse uk</a> <a href="http://www.pickwickcrc.com/nike-flyknit-air-max-vente-herren-schuhec">nike flyknit air max vente herren</a>
    glplawyers http://www.glplawyers.com/

  11. avatar castalresources

    <a href="http://www.dissertationsverlag.net/jordan-super-fly-2-argento-rosso-schuhea">jordan super fly 2 argento rosso</a> <a href="http://www.divxcompare.net/nike-air-force-1-flyknit-low-gituttio-bianca-chaussuresa">nike air force 1 flyknit low gituttio bianca</a> <a href="http://www.dnacf.net/flyknit-lunar-3-fit-rossodit-obuva">flyknit lunar 3 fit rossodit</a> <a href="http://www.doresdecabeca.net/adidas-neo-lazy-p%C3%BArpura-verde-butyc">adidas neo lazy p煤rpura verde</a> <a href="http://www.dorothygrant.net/nike-mercurial-vapor-rosado-kaufen-scarpeb">nike mercurial vapor rosado kaufen</a> <a href="http://www.dotjewelers.net/adidas-springblade-drive-solar-vert-ny-kurpesf">adidas springblade drive solar vert ny</a>
    castalresources http://www.castalresources.net/

  12. avatar c1gkrice

    <a href="http://www.q14rzxj1.com/air-jordan-retro-28-oransje-r%C3%B8d-chaussuresf">air jordan retro 28 oransje r酶d</a> <a href="http://www.9eatxi60.com/air-max-2016-kvinners-rosa-oransje-chaussuresa">air max 2016 kvinners rosa oransje</a> <a href="http://www.6klngb19.com/nike-free-run-2-uk-venta-butya">nike free run 2 uk venta</a> <a href="http://www.nawe264s.com/nike-huarache-rosado-azul-butyc">nike huarache rosado azul</a> <a href="http://www.b0mqjns5.com/nike-blazer-low-gt-skate-sko-scarpeg">nike blazer low gt skate sko</a> <a href="http://www.oiev6b3d.com/curry-3-human-torch-scarpe-nero-chaussuresc">curry 3 human torch scarpe nero</a>
    c1gkrice http://www.c1gkrice.com/

  13. avatar hrubinlaser

    <a href="http://www.dianaandwill.com/adidas-superstar-2-lux-rouge-chaussuresa">adidas superstar 2 lux rouge</a> <a href="http://www.newagecharger.com/elite-devin-funchess-fadeaway-fashion-jersey-carolina-panthers-17-blackblue-nflg">elite devin funchess fadeaway fashion jersey carolina panthers 17 blackblue</a> <a href="http://www.foliekopen.com/air-jordan-retro-12-mens-gold-runningg">air jordan retro 12 mens gold</a> <a href="http://www.milapioffret.com/women-2012-new-nfl-jerseys-san-francisco-49ers-53-navorro-bowman-red-jerseys-hall-of-fames-50th-patch-nflv">women 2012 new nfl jerseys san francisco 49ers 53 navorro bowman red jerseys hall of fames 50th patch</a> <a href="http://www.kalraslan.com/yellow-womens-nike-air-max-2016-trainersa">yellow womens nike air max 2016</a> <a href="http://www.umuttekelbayi.com/nike-free-3.0-bl%C3%A5-gr%C3%A5-gr%C3%B8nn-scarpec">nike free 3.0 bl氓 gr氓 gr酶nn</a>
    hrubinlaser http://www.hrubinlaser.com/

  14. avatar tntkibris

    <a href="http://www.allenchute.com/nike-youth-luke-stocker-limited-olivecamo-jersey-tennessee-titans-nfl-88-2017-salute-to-service-nflx">nike youth luke stocker limited olivecamo jersey tennessee titans nfl 88 2017 salute to service</a> <a href="http://www.belronctx.com/new-blance-574-kinder-minzgr%C3%BCn-kurpesc">new blance 574 kinder minzgr眉n</a> <a href="http://www.divasdelface.com/limited-nike-camo-mens-troy-polamalu-jersey-nfl-43-pittsburgh-steelers-rush-realtree-nflx">limited nike camo mens troy polamalu jersey nfl 43 pittsburgh steelers rush realtree</a> <a href="http://www.dolcemialuxe.com/kvinners-nike-sb-stefan-janoski-max-gull-svart-obuvd">kvinners nike sb stefan janoski max gull svart</a> <a href="http://www.feyzplastik.com/nike-casual-scarpe-bianca-oro-scarpec">nike casual scarpe bianca oro</a> <a href="http://www.oanhsara.com/nike-zoom-winflo-2-hvit-kurpesb">nike zoom winflo 2 hvit</a>
    [url=http://www.tntkibris.com/]tntkibris[/url]

  15. avatar rx3wvk23

    <a href="http://www.tvjuti65.com/adidas-rose-5-bl%C3%A5-guld-obuvc">adidas rose 5 bl氓 guld</a> <a href="http://www.pbyz412s.com/nike-free-run-5.0-rosa-oro-kurpesb">nike free run 5.0 rosa oro</a> <a href="http://www.x745mfcu.com/asics-gel-kayano-20-negro-plum-kurpesd">asics gel kayano 20 negro plum</a> <a href="http://www.dkouevy6.com/air-jordan-11-low-bleu-moon-up-kurpesc">air jordan 11 low bleu moon up</a> <a href="http://www.15wij42f.com/air-jordan-retro-9-gr%C3%BCn-blau-scarped">air jordan retro 9 gr眉n blau</a> <a href="http://www.5k71d4ly.com/nike-air-max-zero-himmelblau-gelb-schuhee">nike air max zero himmelblau gelb</a>
    rx3wvk23 http://www.rx3wvk23.com/

  16. avatar 天津涂装设备

    可以释放很不错啊

  17. avatar 澳门赌场特讯

    谢谢分享啊

欢迎留言




用户登录

sitemap