Hello,
I have a small problem. In a test program, I wrote code to open and save a serialized structure. I created an array of that struct and saved it using binary formater. Everything was great, until I copied the info over to the current project; now I'm getting errors.
This is what I have:
The following is incomplete - errors. The errors are added separately; if I add brackets to LFS:
And if I remove the brackets:
However, if I add brackets to LoadSavedFile, the errors drop. The thing is, LoadSavedFile is the name of the structure which is a single instance/element(?).
I'm confused. I have read for hours, and I have achieved diddly - thankfully, that includes not throwing the beer bottle at the tv (my monitor).
If anyone has an answer or can send me to a good thorough and understandable resource to sort this out, that's cool too. I know VB.net is popular, but sometimes I would like to kick the developers for messing with and removing stuff they shouldn't. I could've had this done in a minute (maybe two) in VB6 using get and put.
Sigh.
Oh well, I have beer and the Clash (whoops, Kings of Leon, now) to keep me company.
Happy Eve',
Shawn
I have a small problem. In a test program, I wrote code to open and save a serialized structure. I created an array of that struct and saved it using binary formater. Everything was great, until I copied the info over to the current project; now I'm getting errors.
This is what I have:
Code:
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Runtime.Serialization.Formatters.Binary
<Serializable()> Structure LoadSavedFile
Public LFN As String 'Loaded File Name, previous filenames
Public LFNF As String 'Loaded full File path
End Structure
Public LFS(100) As LoadSavedFile 'Empty array of filenames
Public BF As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim MS As New System.IO.MemoryStream()
Code:
Public Sub OrdersUp()
'fileserver
BF.Serialize(MS, LFS)
My.Computer.FileSystem.WriteAllBytes("C:\Users\Nepha\Documents\programs.bin", MS.GetBuffer(), False)
Dim bytes As Byte() = My.Computer.FileSystem.ReadAllBytes("C:\Users\Nepha\Documents\programs.bin")
LFS() = DirectCast(BF.Deserialize(New System.IO.MemoryStream(bytes)), LoadSavedFile)
End Sub
Code:
Public Sub OrdersUp()
'fileserver
BF.Serialize(MS, LFS)
My.Computer.FileSystem.WriteAllBytes("C:\Users\Nepha\Documents\programs.bin", MS.GetBuffer(), False)
Dim bytes As Byte() = My.Computer.FileSystem.ReadAllBytes("C:\Users\Nepha\Documents\programs.bin")
LFS = DirectCast(BF.Deserialize(New System.IO.MemoryStream(bytes)), LoadSavedFile)
End Sub
I'm confused. I have read for hours, and I have achieved diddly - thankfully, that includes not throwing the beer bottle at the tv (my monitor).
If anyone has an answer or can send me to a good thorough and understandable resource to sort this out, that's cool too. I know VB.net is popular, but sometimes I would like to kick the developers for messing with and removing stuff they shouldn't. I could've had this done in a minute (maybe two) in VB6 using get and put.
Sigh.
Oh well, I have beer and the Clash (whoops, Kings of Leon, now) to keep me company.
Happy Eve',
Shawn