被二进制文件写入困扰了2天之后终于写出来
先把代码贴上,明天补说明
Imports System
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Public Sub a1(ByVal myStr As String)
Dim bytes As Byte() '定义Byte数组
Dim u32 As Encoding = Encoding.UTF32 '定义转换编码类型UTF32
bytes = u32.GetBytes(myStr) '转换string为byte
My.Computer.FileSystem.WriteAllBytes("CustomerData.dat", bytes, True) '写入dat文件 true表示追加
End Sub
Public Sub a2(ByVal myStr() As String)
Dim bytes As Byte()() = New Byte()() {} '定义Byte数组
Dim u32 As Encoding = Encoding.UTF32 '定义转换编码类型UTF32
Dim i As Integer
For i = 1 To myStr.Length
bytes(i) = u32.GetBytes(myStr(i)) '转换string为byte
My.Computer.FileSystem.WriteAllBytes("CustomerData.dat", bytes(i), True) '写入dat文件 true表示追加
Next
End Sub