c# - Write empty bytes using binarywriter -
so using binarywriter write strings on original strings, need overwrite whole string in binary file, trying write new string, , overwrite rest of old string 0x00 (empty bytes), tried, not working:
bw.write(enc.getbytes(listview1.items[i].subitems[2].text + (31 - enc.getbytecount(listview1.items[i].subitems[2].text)) * '\0'));
31 constant int old strings can't tresspass (don't ask me, it's script thingy)
that's because:
number * '\0' = number * 0 ('\0' converted int) => equal 0
to generate string filled \0
(or char) of length, use:
new string(`\0`, number)
in case:
string newstr = listview1.items[i].subitems[2].text; bw.write(enc.getbytes(newstr + new string('\0', (31 - enc.getbytecount(newstr)))));
Comments
Post a Comment