|
-
Jul 20th, 2007, 01:15 PM
#1
Re: [2005] File IO Problem
Well I just want to start from the code execution on down. So the next line will be ....
Code:
Map(MapNum) = Reader.ReadBytes(Stream.Length)
So to convert this, its basically just a class with some variables. Seems like you are trying to read a file and populate the class at the same time?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 20th, 2007, 03:04 PM
#2
Thread Starter
Addicted Member
Re: [2005] File IO Problem
exactly, i'm trying to read the file straight into the class, and vise-versa for the savelocalmap method.
I read around the internet about this and I think i have it, i should use serialization with my classes.
Code:
Sub LoadMap(ByVal MapNum As Integer)
Dim FileName As String
FileName = Application.StartupPath & "\maps\map" & MapNum & ".dat"
If FileExist(FileName) = False Then Exit Sub
Dim input As IO.FileStream
Dim reader As Runtime.Serialization.Formatters.Binary.BinaryFormatter = New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
input = New IO.FileStream(FileName, IO.FileMode.Open, IO.FileAccess.Read)
Try
Map(MapNum) = CType(reader.Deserialize(input), MapRec)
Catch serializableException As Runtime.Serialization.SerializationException
input.Close()
End Try
input.Close()
End Sub
thats my code now, but im getting an error, let me bring it up again...just a sec...
The input stream is not a valid binary format. The starting contents (in bytes) are: 20-20-20-20-20-20-20-20-20-20-20-20-20-20-20-20-20 ...
for line
Code:
Map(MapNum) = CType(reader.Deserialize(input), MapRec)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|