基本上我想要的只是将 Gziped 文件加载到富文本框中。我在 MS .NET 站点上找到了一些用于解压缩文件的代码。现在我想将该流指向一个富文本框,但我不断收到错误“非静态字段、方法或属性'WindowsFormsApplication1.Form1.richTextBox1'需要对象引用”
代码在这里。我究竟做错了什么?提前致谢。
public static void Decompress(FileInfo fi)
{
// Get the stream of the source file.
using (FileStream inFile = fi.OpenRead())
{
// Get original file extension, for example
// "doc" from report.doc.gz.
string curFile = fi.FullName;
string origName = curFile.Remove(curFile.Length -
fi.Extension.Length);
//Create the decompressed file.
using (FileStream outFile = File.Create(origName))
{
using (GZipStream Decompress = new GZipStream(inFile,
CompressionMode.Decompress))
{
// Copy the decompression stream
// into the output file.
Decompress.CopyTo(outFile);
richTextBox1.LoadFile(Decompress.CopyTo(outFile), RichTextBoxStreamType.PlainText);
// problem right here ^^^^
}//using
}//using
}//using
}//DeCompress