MIT писал(а):Вот запись:Наверное тоже работает верно
- Код: Выделить всё
Public Function WriteFile(ByVal path As String, ByVal File As FileData, ByVal overwrite As Boolean) As Boolean
If IO.File.Exists(path) And Not overwrite Then Return False
Try
Using fs As New IO.FileStream(path, IO.FileMode.Create, IO.FileAccess.Write)
Dim bw As New IO.BinaryWriter(fs)
Dim buff() As Byte
With File
buff = System.Text.ASCIIEncoding.Default.GetBytes(.header)
ReDim Preserve buff(4)
bw.Write(buff)
bw.Write(.CountOfItems)
For i As Integer = 0 To .CountOfItems - 1
With .Data(i)
bw.Write(.id)
buff = System.Text.ASCIIEncoding.Default.GetBytes(.text1)
ReDim Preserve buff(23)
bw.Write(buff)
bw.Write(.CountOfSubItems)
For j As Integer = 0 To .CountOfSubItems - 1
buff = System.Text.ASCIIEncoding.Default.GetBytes(.Data(j))
ReDim Preserve buff(239)
bw.Write(buff)
Next
End With
Next
buff = System.Text.ASCIIEncoding.Default.GetBytes(.footer)
ReDim Preserve buff(4)
bw.Write(buff)
End With
End Using
Return True
Catch ex As Exception
Return False
End Try
End Function
FilePut(1,MyStruct, 1)
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1