I have a problem in my C# program. I am currently developing a gateway (both TCP and UDP protocols), and have to log the traffic to a file. I got some test data to try my gateway with. Example data: ASYRE\x00\x00\x01.
My program should log this into a file, and here comes my problem: When logging to the file (or writing it onto the Console) i get ASYRE, and the special \x00\x00\x01 characters will be decoded in the file, however, i have to log them as they came in, so when logging they should be "ASYRE\x00\x00\x01".
I tried using Encoding.Default.GetString()
, Convert.ToString()
, Parse
and even Regex
, but I don't know how to get it to be logged correctly.