基本的には、Gzip ファイルをリッチ テキスト ボックスにロードするだけです。ファイルを解凍するためのコードが 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