是否可以嵌入压缩文本文件,然后在运行时解压缩或从中读取? [英] Is it possible to embed a zipped text file, then unzip or read from it at runtime?

查看:92
本文介绍了是否可以嵌入压缩文本文件,然后在运行时解压缩或从中读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请原谅我的无知,因为我是一名自学成才的业余爱好者。


读完SharpZipLib后我很好奇。我可以在我的程序中嵌入一个压缩的txt文件

吗?然后从zip文件中读取或解压缩并阅读

吗?我目前有一个嵌入式文本文件,其中包含一个读入数组的
列表。我总是希望节省空间。如果它是压缩的,我可以减少我的

文件大小75%!我查看了SharpZipLib网站,

下载了他们的例子。我没有看到任何证明这一点。他们

主要似乎是在本地

驱动器上展示压缩/解压缩文件/文件夹。


提前谢谢:)

pardon my ignorance as I am a self-taught hobbyist programmer.

I am curious after reading up on SharpZipLib. Can I embed a zipped txt file
in my program? Then either read from within the zip file or unzip and read
it? I currently have an embedded text file that contains a list that is
read into an array. I''m always looking to save space. And I could reduce my
file size 75% if it was zipped! I have looked at the SharpZipLib web site,
downloaded their examples. I don''t see any that demonstrate this. They
mainly seem to demonstrate zipping/unzipping files/folders on the local
drives.

Thanks in advance :)

推荐答案

您好,


您可以将压缩文件作为二进制数据嵌入资源文件中。将这些数据提取到流中,然后将
传递给SharpZipLib,就好像它是一个文件流一样。这应该工作

罚款。


-c

http://www.typemismatch.com/

" Yogi_Bear_79" < IT ***** @ spamfree.com>在消息中写道

新闻:Eq ******************** @ comcast.com ...
Hi,

You can embed your zipped file as binary data in a resource file. Extract
this data into a Stream and
pass it to the SharpZipLib as if it was a file stream. This should work
fine.

-c

http://www.typemismatch.com/

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:Eq********************@comcast.com...
原谅我的无知,因为我是一个自学成才的业余爱好者。

我在读完SharpZipLib后很好奇。我可以在程序中嵌入一个压缩的txt
文件吗?然后从zip文件中读取或解压缩并阅读
它?我目前有一个嵌入式文本文件,其中包含一个读入数组的列表。我总是希望节省空间。如果是压缩文件,我可以将文件大小减少75%!我查看了SharpZipLib网站,
下载了他们的例子。我没有看到任何证明这一点。他们
主要似乎是在本地
驱动器上展示压缩/解压缩文件/文件夹。

提前致谢:)
pardon my ignorance as I am a self-taught hobbyist programmer.

I am curious after reading up on SharpZipLib. Can I embed a zipped txt
file
in my program? Then either read from within the zip file or unzip and read
it? I currently have an embedded text file that contains a list that is
read into an array. I''m always looking to save space. And I could reduce
my
file size 75% if it was zipped! I have looked at the SharpZipLib web site,
downloaded their examples. I don''t see any that demonstrate this. They
mainly seem to demonstrate zipping/unzipping files/folders on the local
drives.

Thanks in advance :)



你有什么机会给出一个如何做到这一点的例子吗?目前文件

是.txt你是否正在将其转换为二进制,然后压缩它。使用

SharpZipLib在运行时将其解压缩以读取它的内容?一直

保持一切嵌入,所以我的.exe是独立的?

" typeMisMatch" <是ne ** @ ip80.com>在消息中写道

news:u9 ************* @ TK2MSFTNGP09.phx.gbl ...
Any chance you coud give an example of how to do this? Currently the file
is a .txt Are yousaying convert it to binary, then zip it. THen use
SharpZipLib to unzip it at run time to read it''s contents? All the while
keeping everything embedded so my .exe is stand alone?
"typeMisMatch" <ne**@ip80.com> wrote in message
news:u9*************@TK2MSFTNGP09.phx.gbl...


您可以将压缩文件作为二进制数据嵌入资源文件中。将此数据提取到Stream中并将其传递给SharpZipLib,就好像它是一个文件流一样。这应该工作
很好。

-c

http://www.typemismatch.com/

" Yogi_Bear_79" < IT ***** @ spamfree.com>在消息中写道
新闻:Eq ******************** @ comcast.com ...
Hi,

You can embed your zipped file as binary data in a resource file. Extract
this data into a Stream and
pass it to the SharpZipLib as if it was a file stream. This should work
fine.

-c

http://www.typemismatch.com/

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:Eq********************@comcast.com...
请原谅我的无知我是一名自学成才的业余爱好者。

我在读完SharpZipLib后很好奇。我可以在程序中嵌入一个压缩的txt
文件吗?然后从zip文件中读取或解压缩并且
读取它?我目前有一个嵌入式文本文件,其中包含一个读入数组的列表。我总是希望节省空间。如果它是压缩的话,我可以
减少我的文件大小75%!我查看了SharpZipLib网站
网站,下载了他们的例子。我没有看到任何证明这一点。他们
主要似乎是在本地
驱动器上展示压缩/解压缩文件/文件夹。

提前致谢:)
pardon my ignorance as I am a self-taught hobbyist programmer.

I am curious after reading up on SharpZipLib. Can I embed a zipped txt
file
in my program? Then either read from within the zip file or unzip and read it? I currently have an embedded text file that contains a list that is
read into an array. I''m always looking to save space. And I could reduce my
file size 75% if it was zipped! I have looked at the SharpZipLib web site, downloaded their examples. I don''t see any that demonstrate this. They
mainly seem to demonstrate zipping/unzipping files/folders on the local
drives.

Thanks in advance :)






我想你也可以将你的拉链添加到你的解决方案

和属性中它指定一个嵌入式资源


然后你可以使用ResourceManager读取文件

class


google for C#ResourceManager嵌入式,我相信你会得到一些例子


I think you could also add your zip into your solution
and in the properties for it specify an embedded resource

You could then read the file using ResourceManager
class

google for C# ResourceManager embedded and I am sure you
will get some examples

-----原帖-----
你有什么机会给出一个如何做到这一点的例子吗?
目前该文件是.txt你是否正在将其转换为二进制,然后压缩
它。使用SharpZipLib在运行时将其解压缩以读取它的
内容?所有内容都是嵌入式的,所以我的.exe是独立的吗?

" typeMisMatch" <是ne ** @ ip80.com>在消息中写道
新闻:u9 ************* @ TK2MSFTNGP09.phx.gbl ...
-----Original Message-----
Any chance you coud give an example of how to do this? Currently the fileis a .txt Are yousaying convert it to binary, then zip it. THen useSharpZipLib to unzip it at run time to read it''s contents? All the whilekeeping everything embedded so my .exe is stand alone?
"typeMisMatch" <ne**@ip80.com> wrote in message
news:u9*************@TK2MSFTNGP09.phx.gbl...


您可以将压缩文件作为二进制数据嵌入
资源文件中。将
Hi,

You can embed your zipped file as binary data in a resource file. Extract
提取到Stream中,然后将其传递给SharpZipLib,就好像它是一个文件流一样。
这应该可以正常工作。

-c

http://www.typemismatch.com/

" Yogi_Bear_79" < IT ***** @ spamfree.com>在消息中写道
新闻:Eq ******************** @ comcast.com ...
this data into a Stream and
pass it to the SharpZipLib as if it was a file stream. This should work fine.

-c

http://www.typemismatch.com/

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:Eq********************@comcast.com...
>原谅我的无知,因为我是一个自学成才的爱好者
程序员。 >
>
>
>阅读SharpZipLib后我很好奇。可以我
嵌入一个压缩的txt>文件
>在我的程序?然后从zip
文件中读取或解压缩并且
> pardon my ignorance as I am a self-taught hobbyist programmer. >
>
>
> I am curious after reading up on SharpZipLib. Can I embed a zipped txt > file
> in my program? Then either read from within the zip file or unzip and
read>它?我目前有一个嵌入式文本文件
read > it? I currently have an embedded text file that


包含一个>列表读入数组。我总是希望节省
的空间。我可以

contains a list that is > read into an array. I''m always looking to save space. And I could

reduce>我的
>如果是压缩文件大小75%!我查看了
reduce > my
> file size 75% if it was zipped! I have looked at the


SharpZipLib web

SharpZipLib web

site,>下载他们的例子。我没有看到任何
site, > downloaded their examples. I don''t see any that



证明这一点。他们>主要似乎是在本地>上演示了压缩/解压缩
文件/文件夹驱动器。
>
>
>
>在此先感谢:)
>
>


demonstrate this. They > mainly seem to demonstrate zipping/unzipping files/folders on the local > drives.
>
>
>
> Thanks in advance :)
>
>





.



这篇关于是否可以嵌入压缩文本文件,然后在运行时解压缩或从中读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆