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

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

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#
看了本文是不是觉得很赞,那就赶紧点击下面按钮分享给身边的朋友吧!

9 条评论

  1. avatar linnwoodpark

    <a href="http://www.douhenhar.com/nike-free-flyknit-4.0-v2-red-black-shoesj">nike free flyknit 4.0 v2 red black</a> <a href="http://www.bigdstattoos.com/boston-celtics-47-nba-summerland-clean-up-cap-hath">boston celtics 47 nba summerland clean up cap</a> <a href="http://www.popuptucasa.com/amarillo-oro-converse-zapatosl">amarillo oro converse</a> <a href="http://www.mapspokemon.com/nike-air-jordan-4-red-shoesk">nike air jordan 4 red</a> <a href="http://www.aevibox.com/nike-free-run-2-kvinner-rosa-hvit-obuvi">nike free run 2 kvinner rosa hvit</a> <a href="http://www.dikkertjedap.com/mennns-nike-air-max-95-lilla-gr%C3%A5-obuvk">mennns nike air max 95 lilla gr氓</a>
    linnwoodpark http://www.linnwoodpark.com/

  2. avatar biddingstream

    <a href="http://www.mandydugan.com/nike-lunarglide-6-himmelen-bl%C3%A5-gr%C3%A5-obuvl">nike lunarglide 6 himmelen bl氓 gr氓</a> <a href="http://www.dxnkofe.com/herre-nike-air-huarache-nm-appelsin-bl%C3%A5-skoj">herre nike air huarache nm appelsin bl氓</a> <a href="http://www.yurasmirnov.com/adidas-neo-mesh-gituttio-oro-scarpel">adidas neo mesh gituttio oro</a> <a href="http://www.blovese.com/nike-roshe-run-high-green-silver-shoesj">nike roshe run high green silver</a> <a href="http://www.ztsurfboards.com/air-jordan-cp3-sort-himmelbl%C3%A5-skok">air jordan cp3 sort himmelbl氓</a> <a href="http://www.visheshcap.com/kvinners-nike-free-run-2-gul-gr%C3%A5-obuvp">kvinners nike free run 2 gul gr氓</a>
    biddingstream http://www.biddingstream.com/

  3. avatar swiftgrocer

    <a href="http://www.profancyshop.com/nike-kobe-9-gr%C3%A5-oransje-obuvi">nike kobe 9 gr氓 oransje</a> <a href="http://www.lmcgroep.com/ua-micro-g-torch-viola-blu-scarpej">ua micro g torch viola blu</a> <a href="http://www.nowaitnails.com/adidas-neo-ventilation-black-gold-shoesh">adidas neo ventilation black gold</a> <a href="http://www.xmrujo.com/nike-air-max-neon-amarillo-zapatosp">nike air max neon amarillo</a> <a href="http://www.sevenguard.com/mujeres-air-jordan-7-verde-zapatosk">mujeres air jordan 7 verde</a> <a href="http://www.escortsue.com/north-face-apex-bionic-asphalt-grey-heather-northfaceh">north face apex bionic asphalt grey heather</a>
    swiftgrocer http://www.swiftgrocer.com/

  4. avatar pokersurga

    <a href="http://www.lvnailbar.com/adidas-tubular-nova-primeknit-r%C3%B8d-skol">adidas tubular nova primeknit r酶d</a> <a href="http://www.eisenhards.com/adidas-hvit-sports-sko-obuvk">adidas hvit sports sko</a> <a href="http://www.martinmakeup.com/nike-air-max-90-femminile-wholevendita-bianca-scarpei">nike air max 90 femminile wholevendita bianca</a> <a href="http://www.dgrabovsky.com/nike-free-run-3-hombres-rojo-blanco-corriendo-zapatos-zapatosh">nike free run 3 hombres rojo blanco corriendo zapatos</a> <a href="http://www.madeinmyindia.com/nike-air-max-lyser%C3%B8d-gr%C3%B8n-skok">nike air max lyser酶d gr酶n</a> <a href="http://www.manglammovers.com/adidas-superstar-sko-rosa-obuvi">adidas superstar sko rosa</a>
    pokersurga http://www.pokersurga.com/

  5. avatar milliemummery

    <a href="http://www.noumoles.com/nike-blazer-low-vintage-noir-reptile-butyc">nike blazer low vintage noir reptile</a> <a href="http://www.pikespeakshop.com/adidas-climacool-ride-iv-jaune-orange-obuvg">adidas climacool ride iv jaune orange</a> <a href="http://www.sozihoster.com/air-max-90-wolf-grigio-ice-kurpesa">air max 90 wolf grigio ice</a> <a href="http://www.theblases.com/adidas-neo-leisure-guld-sort-kurpese">adidas neo leisure guld sort</a> <a href="http://www.allbidder.com/ralph-lauren-tan-l%C3%A6r-bag-polou">ralph lauren tan l忙r bag</a> <a href="http://www.artstrava.com/nike-free-run-3-azul-and-rosado-scarpeb">nike free run 3 azul and rosado</a>
    milliemummery http://www.milliemummery.com/

  6. avatar timowallets

    <a href="http://www.matrawildlife.com/menn-nike-kobe-9-high-bl%C3%A5-gr%C3%A5-gr%C3%B8nn-hvit-obuvk">menn nike kobe 9 high bl氓 gr氓 gr酶nn hvit</a> <a href="http://www.hiyawigs.com/coach-poppy-blaire-in-sequin-signature-small-red-totes-coachh">coach poppy blaire in sequin signature small red totes</a> <a href="http://www.fidgefingers.com/femminile-nike-zoom-structure-20-nero-rosa-scarpej">femminile nike zoom structure 20 nero rosa</a> <a href="http://www.lintvan.com/air-max-2014-femminile-marina-militare-blu-viola-rosso-arancia-scarpei">air max 2014 femminile marina militare blu viola rosso arancia</a> <a href="http://www.pubgdust.com/arizona-cardinals-new-era-nfl-shadowed-team-flex-cap-hath">arizona cardinals new era nfl shadowed team flex cap</a> <a href="http://www.ahtantalya.com/nike-sb-dunk-low-frougedy-krueger-chaussuresh">nike sb dunk low frougedy krueger</a>
    [url=http://www.timowallets.com/]timowallets[/url]

  7. avatar skonya

    <a href="http://www.awassessment.com/ray-ban-rb4147-sunglasses-brown-frame-crystal-deep-brown-gradien-sunglassesh">ray ban rb4147 sunglasses brown frame crystal deep brown gradien</a> <a href="http://www.websiteopmaat.com/nike-free-run-3.0-flyknit-noir-chaussuresl">nike free run 3.0 flyknit noir</a> <a href="http://www.lopifitfl.com/adidas-zx-flux-noir-and-or-sole-chaussuresl">adidas zx flux noir and or sole</a> <a href="http://www.aurorefleurs.com/nike-free-run-5.0-dam%C3%A4nner-rot-schuhej">nike free run 5.0 dam盲nner rot</a> <a href="http://www.ezedcal.com/adidas-porsche-design-iii-p5000-m%C3%A4nner-schwarz-gr%C3%BCn-schuhei">adidas porsche design iii p5000 m盲nner schwarz gr眉n</a> <a href="http://www.calsportswear.com/menn-nike-dunk-low-deep-light-brun-obuvj">menn nike dunk low deep light brun</a>
    skonya http://www.skonya.com/

  8. avatar 天津涂装设备

    可以释放很不错啊

  9. avatar 澳门赌场特讯

    谢谢分享啊

欢迎留言




用户登录

sitemap