本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# InflaterInputStream.Dispose方法的具体用法?C# InflaterInputStream.Dispose怎么用?C# InflaterInputStream.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream
的用法示例。
在下文中一共展示了InflaterInputStream.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseQpyd
private string ParseQpyd(string qqydFile)
{
var fs = new FileStream(qqydFile, FileMode.Open, FileAccess.Read);
fs.Position = 0x38;
var startAddressByte = new byte[4];
fs.Read(startAddressByte, 0, 4);
int startAddress = BitConverter.ToInt32(startAddressByte, 0);
fs.Position = 0x44;
int wordCount = BinFileHelper.ReadInt32(fs);
CountWord = wordCount;
CurrentStatus = 0;
fs.Position = startAddress;
var zipStream = new InflaterInputStream(fs);
int bufferSize = 2048; //缓冲区大小
int readCount = 0; //读入缓冲区的实际字节
var buffer = new byte[bufferSize];
var byteList = new List<byte>();
readCount = zipStream.Read(buffer, 0, bufferSize);
while (readCount > 0)
{
for (int i = 0; i < readCount; i++)
{
byteList.Add(buffer[i]);
}
readCount = zipStream.Read(buffer, 0, bufferSize);
}
zipStream.Close();
zipStream.Dispose();
fs.Close();
byte[] byteArray = byteList.ToArray();
int unzippedDictStartAddr = -1;
int idx = 0;
var sb = new StringBuilder();
while (unzippedDictStartAddr == -1 || idx < unzippedDictStartAddr)
{
// read word
int pinyinStartAddr = BitConverter.ToInt32(byteArray, idx + 0x6);
int pinyinLength = BitConverter.ToInt32(byteArray, idx + 0x0) & 0xff;
int wordStartAddr = pinyinStartAddr + pinyinLength;
int wordLength = BitConverter.ToInt32(byteArray, idx + 0x1) & 0xff;
if (unzippedDictStartAddr == -1)
{
unzippedDictStartAddr = pinyinStartAddr;
Debug.WriteLine("词库地址(解压后):0x" + unzippedDictStartAddr.ToString("0x") + "\n");
}
string pinyin = Encoding.UTF8.GetString(byteArray, pinyinStartAddr, pinyinLength);
string word = Encoding.Unicode.GetString(byteArray, wordStartAddr, wordLength);
sb.Append(word + "\t" + pinyin + "\n");
Debug.WriteLine(word + "\t" + pinyin);
CurrentStatus++;
// step up
idx += 0xa;
}
return sb.ToString();
}