How to read and write interoperable strings to a binary file between .NET and vb6

前端 未结 1 1226
别那么骄傲
别那么骄傲 2021-01-18 05:31

I have a new program I am writing in C#, it will need to read and write binary files that are compatible with vb6\'s binary format. I can not change the vb6 program but I ca

相关标签:
1条回答
  • 2021-01-18 06:27

    It is simply a short that contains the string length, use BinaryWriter(short). Don't use BinaryWriter.Write(string), use BinaryWriter.Write(byte[]) where you got the byte[] from Encoding.Default.GetBytes().

    Intentional avoiding the compat functions in the Microsoft.VisualBasic namespace might not the be most productive approach. It doesn't byte, the framework doesn't care what language you use. Have a look at Microsoft.VisualBasic.FileSystem.FilePut(). Available in any .NET framework version, that's code you won't have to maintain and has been tested by thousands. You do have to add an assembly reference to Microsoft.VisualBasic.

    0 讨论(0)
提交回复
热议问题