Basically all I want is to load a Gziped file into a rich text box. I found some code on the MS .NET site for decompressing the file. Now I want to point that stream to a rich text box, but I keep getting the error "An object reference is required for the non-static field, method, or property 'WindowsFormsApplication1.Form1.richTextBox1' "
Code is here. What am I doing wrong? Thanks in advance.
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