C++ 代码转 C#

悦澜殇 发布于 2016/06/03 19:37
阅读 375
收藏 0
C++
wxByte* pBuffer = buffer;
buffer = deflate(buffer, size, 276);
wxDELETEA(pBuffer);

wxMemoryInputStream mis(buffer, 276);
wxDataInputStream bis(mis);
mis.Read(fte.filePath, 260);

C#

byte[] pBuffer = buffer;
buffer = deflate(buffer, size, 276);

MemoryStream mis = new MemoryStream(buffer, 0, 276);
BinaryReader bis = new BinaryReader(mis);

mis.Read(fte.filePath, 0, size);

wxMemoryInputStream & MemoryStream

wxDataInputStream & BinaryReader

C++ 得到的是正确的目录和文件或者文件

C# 是错误的乱码,已经试过不同的编码,都不对,望大神解惑

以下是问题补充:

@悦澜殇:C++ wxByte* deflate(wxByte * buffer, wxUint32 sizeCompressed, wxUint32 sizeDecompressed) { wxByte* out = new wxByte[sizeDecompressed]; wxMemoryInputStream mis(buffer, sizeCompressed); wxZlibInputStream* zis = new wxZlibInputStream(mis); zis->Read(out, sizeDecompressed); wxDELETE(zis); return out; } C# private byte[] deflate(byte[] buffer, int sizeCompressed,int sizeDecompressed) { byte[] outb = new byte[sizeDecompressed]; MemoryStream mis = new MemoryStream(buffer, 0, sizeCompressed); //ZLibStream zis = new ZLibStream(mis, CompressionMode.Decompress); //GZipStream zis = new GZipStream(mis, CompressionMode.Compress); DeflateStream zis = new DeflateStream(mis, CompressionMode.Decompress); zis.BaseStream.Read(outb, 0, sizeDecompressed); //zis.Read(outb, 0, sizeDecompressed); mis.Close(); zis.Close(); return outb; } (2016/06/03 19:41)
加载中
返回顶部
顶部