Home > Software engineering >  VB.NET file read and write the problem why the written Chinese is two characters, reading Chinese is
VB.NET file read and write the problem why the written Chinese is two characters, reading Chinese is

Time:10-03

As title, VB.NET, I read and write a file,
Dim the fs As FileStream=New FileStream (StrFilePath, FileMode OpenOrCreate)
Dim bw As BinaryWriter=New BinaryWriter (fs)
Dim br As BinaryReader=New BinaryReader (fs)

When I write, assumption is 8 bytes written four Chinese, when I read the eight characters, read it out of there are eight Chinese?
What reason is this???????

CodePudding user response:

BinaryWriter/BinaryReader, speaking, reading and writing is a byte array,
As for an array of bytes and string conversion between, only if you want to use the same Encoding,
  • Related