L
Luc The Perverse
I have a class called "HistoryLog" which has a member variable of type
StreamWriter which is initialized in the constructor.
When I tested it on small outputs, nothing would write to the file, so I
looked in the documentation and found out the Close() function was
supposed to be called (or to use a "using" tag)
So I made a Dispose function and kept getting a FileNotOpen() error.
Searching google I found examples of people doing exactly what I was
doing, asking for help and being told there was basically no way to make
it work in this fashion.
Now I have 2 questions:
1. I am using a workaround, calling Flush() after every log write, and
never explicitly calling Close(). Is there any downside/danger to this
method?
2. Is there a better way to make a history log class that will take
care of ensuring the buffer gets emptied in it's dispose functional (or
some other way?)
My goal was to make a class which I could instantiate once, write to if
/ when needed and not have to worry about it again - a habit I got used
to in C++. If this is no longer feasible, I suppose I could get over
it. hehe
Thanks
StreamWriter which is initialized in the constructor.
When I tested it on small outputs, nothing would write to the file, so I
looked in the documentation and found out the Close() function was
supposed to be called (or to use a "using" tag)
So I made a Dispose function and kept getting a FileNotOpen() error.
Searching google I found examples of people doing exactly what I was
doing, asking for help and being told there was basically no way to make
it work in this fashion.
Now I have 2 questions:
1. I am using a workaround, calling Flush() after every log write, and
never explicitly calling Close(). Is there any downside/danger to this
method?
2. Is there a better way to make a history log class that will take
care of ensuring the buffer gets emptied in it's dispose functional (or
some other way?)
My goal was to make a class which I could instantiate once, write to if
/ when needed and not have to worry about it again - a habit I got used
to in C++. If this is no longer feasible, I suppose I could get over
it. hehe
Thanks