小编kit*_*ite的帖子

GZipStream和DeflateStream会生成更大的文件

我正在尝试在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)

c# gzipstream deflatestream

9
推荐指数
1
解决办法
4710
查看次数

WCF VS. 套接字

我想知道哪个WCF或.NET套接字效率更高,而且在游戏开发场景中推荐的更多.

以下是游戏的不同部分:

- 在互联网上播放的客户端/服务器通信

- 在本地网络上对等.

我想知道你将在这些部件上使用哪种技术(两者都是wcf,两者都是套接字,另一端是wcf,另一端是套接字......)以及为什么,如果可能的话.

涉及的游戏不需要高通信频率(每秒3-4个就足够了).

.net c# sockets wcf

9
推荐指数
2
解决办法
2万
查看次数

silverlight中的byte []到BitmapImage

出于游戏的目的,我需要使用bitmapEncoder及其子类通过WPF应用程序在二进制文件中序列化一些图片.

但是这些类在silverlight中不可用,所以我不能从同一个二进制文件加载到浏览器中.

有人知道如何在silverlight中将byte []转换为BitmapImage吗?

谢谢,

风筝

c# bytearray bitmapimage

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×3

.net ×1

bitmapimage ×1

bytearray ×1

deflatestream ×1

gzipstream ×1

sockets ×1

wcf ×1