Hi, I'm working on a project wherein I need to pull out 256 bytes from a specified position in a file. The 256 bytes represent the title of the file. The thing is, it's null-padded, so there are 2 null hex bytes before the string starts, a single null byte between each letter in the title, and a variable number of nulls after the title ends. For example, if my title was "some random title", I would have 256 bytes with the first 2 being "00 00", then the title with a single "00" byte between each letter, and 221 "00" bytes after.
I need to know how to get rid of those null bytes. I've tried using:
ASCIIEncoding.A SCII.GetString( byte[] bytes);
And that would return a string "some random title" but when I do string.Length I get 256, because null bytes are non-printable when converted to ASCII, but they're still there.
Is there anything I can do? I can't really do any more work on my project until this gets resolved.
I need to know how to get rid of those null bytes. I've tried using:
ASCIIEncoding.A SCII.GetString( byte[] bytes);
And that would return a string "some random title" but when I do string.Length I get 256, because null bytes are non-printable when converted to ASCII, but they're still there.
Is there anything I can do? I can't really do any more work on my project until this gets resolved.
Comment