A
Andrew Falanga
Hi,
On the heals of my previous post I'm now asking for the proper way of
writing text and binary data to a log file. I have a class, in the
singleton pattern, that will be used for logging program operations to
a file. I'm having trouble with using the two.
I eventually ended up at a point of using a FileStream object as a
"base" and then, in my class, also having a BinaryWriter and a
StreamWriter object both taking the FileStream object as an argument
for construction. I ended up with some very odd results when trying
to use these two objects in tandem.
I then noticed that the BinaryWriter object had member functions that
took string objects and such and decided to use only a BinaryWriter
object. This has proven unproductive too. The string objects I pass
are being written to the log file as text but there is extra
characters in the mix. What am I missing? Is this something with the
encoding of the file (UTF8 and so forth)?
I expect that I will be primarily logging text to this log file, but I
can see that the need can arise, as I write this application, that
writing binary data will be necessary. I need to write it into the
same file. Any help is most appreciated.
Thanks,
Andy
On the heals of my previous post I'm now asking for the proper way of
writing text and binary data to a log file. I have a class, in the
singleton pattern, that will be used for logging program operations to
a file. I'm having trouble with using the two.
I eventually ended up at a point of using a FileStream object as a
"base" and then, in my class, also having a BinaryWriter and a
StreamWriter object both taking the FileStream object as an argument
for construction. I ended up with some very odd results when trying
to use these two objects in tandem.
I then noticed that the BinaryWriter object had member functions that
took string objects and such and decided to use only a BinaryWriter
object. This has proven unproductive too. The string objects I pass
are being written to the log file as text but there is extra
characters in the mix. What am I missing? Is this something with the
encoding of the file (UTF8 and so forth)?
I expect that I will be primarily logging text to this log file, but I
can see that the need can arise, as I write this application, that
writing binary data will be necessary. I need to write it into the
same file. Any help is most appreciated.
Thanks,
Andy