How do I get the current write-position using the BinaryWriter. I need to store the position in order to read from that position afterwards. (I know it would give the position where the next write would start, that will be taken care of).
Thanks
Printable View
How do I get the current write-position using the BinaryWriter. I need to store the position in order to read from that position afterwards. (I know it would give the position where the next write would start, that will be taken care of).
Thanks
The BinaryWriter doesn't expose that information but when you created the BinaryWriter you passed it a Stream, which has a Position property. That property will throw an exception if the Stream doesn't support seeking, e.g. a NetworkStream. You'll be fine with a FileStream though, which is the most common backing store.
I did it again, looking at the wrong spot all the time!
I'm using a filestream already, but I was looking at the Binarywriter to find the actual position, a short look at the Filestream did give the information as needed!
Thanks.