我正在尝试在C#中使用deflate/gzip流,但看起来压缩后的文件比以前更大.
例如,我压缩了900ko的docx文件,但它产生了1.4Mo!
它为我尝试过的每个文件都做到了.
我做错的方式可能是我错了吗?这是我的代码:
FileStream input = File.OpenRead(Environment.CurrentDirectory + "/file.docx");
FileStream output = File.OpenWrite(Environment.CurrentDirectory + "/compressedfile.dat");
GZipStream comp = new GZipStream(output, CompressionMode.Compress);
while (input.Position != input.Length)
comp.WriteByte((byte)input.ReadByte());
input.Close();
comp.Close(); // automatically call flush at closing
output.Close();
Run Code Online (Sandbox Code Playgroud) 我想知道哪个WCF或.NET套接字效率更高,而且在游戏开发场景中推荐的更多.
以下是游戏的不同部分:
- 在互联网上播放的客户端/服务器通信
- 在本地网络上对等.
我想知道你将在这些部件上使用哪种技术(两者都是wcf,两者都是套接字,另一端是wcf,另一端是套接字......)以及为什么,如果可能的话.
涉及的游戏不需要高通信频率(每秒3-4个就足够了).
出于游戏的目的,我需要使用bitmapEncoder及其子类通过WPF应用程序在二进制文件中序列化一些图片.
但是这些类在silverlight中不可用,所以我不能从同一个二进制文件加载到浏览器中.
有人知道如何在silverlight中将byte []转换为BitmapImage吗?
谢谢,
风筝