Hi waseywb,
欢迎来到MSDN论坛。
根据我的了解,VS2005应该是使用的.NET Framework 版本是2.0版本(你查看一下的你的.NET Framework 版本).
在使用2.0版本的时候,代码需要手动指定字体编码的格式。比如下面的代码.
private string ReadAuthor(Stream binary_file) {
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
// Read string from binary file with UTF8 encoding
byte[] buffer = new byte[30];
binary_file.Read(buffer, 0, 30);
return encoding.GetString(buffer);
}
如果使用的是VS2015,.NET Framework 应该是3.5以上,默认就是UTF-8的编码方式。
MSDN有提供代码给我们测试,你可以参考一下这个
https://msdn.microsoft.com/en-us/library/744y86tc%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
所以我觉得应该是你编码,没有指定的原因造成这样。
Best Regards,
Hart
如果你的问题解决了,请及时标记有用的回复作为答案,这样会帮助遇到相同问题的人,并且也会提高论坛的活跃度。
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints
to MSDN Support, feel free to contact MSDNFSF@microsoft.com.