斑竹帮我看看为什么解压后失败呢,第一段是把fpspread压缩到一个文件中,第二段是从压缩文件中读出来,但读取老是报错
private void button2_Click(object sender, EventArgs e)
{
FileStream fs = null;
var file = "test.fs";
try
{
fs = new FileStream(file, FileMode.Create, FileAccess.ReadWrite);
DeflateStream zipStream = new DeflateStream(fs, CompressionMode.Compress);
spdData.Save(zipStream, false);
fs.Flush();
zipStream.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
fs.Close();
}
}
private void button3_Click(object sender, EventArgs e)
{
var file = "test.fs";
spdData.Sheets.Clear();
FileStream fs = null;
try
{
fs = new FileStream(file, FileMode.Open, FileAccess.Read);
DeflateStream unZipStream = new DeflateStream(fs, CompressionMode.Decompress, true);
spdData.Open(unZipStream);
unZipStream.Close();
MessageBox.Show("ok");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
fs.Close();
}
} |