I am writing a small application in which I want to write the results of operations to a file.
Basically, what I want to do is open the stream to a file (I think FileStream is open to suggestions), write the data to the file, and then close it later.
So, I have a class called ReportFile , with methods:
.Create( string path ) .WriteInfo( string a, string b, string c ) ;
Thus, a class using the ReportFile class will instantiate, call WriteInfo(..) several times until it finishes doing what it needs to do, and then call Close() at some point in the future.
Now I know that I need to implement the Dispose template in the ReportFile class, to make sure that if something goes about this, process the file descriptor.
However, I have not yet been able to find anything on the website showing a good way to keep the file open, and then check if it needs to be closed, most examples just open the file, write it, then close it - everything is inside the using{} construct.
In the ReportFile class , I want to check if the FileStream instance is closed so that I can close it and free the resource.
Does anyone know a good link to link or any other tips?
(Oh, I have to mention that I do not do C # full time, this is just a hobby, so if this is a stupid question, my apologies ;-)