Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deserialize binary file from vb6

Status
Not open for further replies.

tuckamore

Programmer
Aug 26, 2006
2
CA
I am using Visual Studio 2005 to develop the application and would like to open a binary file that was saved in a Visual Basic 6 application. The binary
file contains one record: a user defined type.

Using:

Imports System.Runtime.Serialization.Formatters.Binary

fStream = New FileStream(strFilename, FileMode.Open)
strucThisproject = CType(binFormat.Deserialize(fStream), _
ProjectStruct)

This catches the message:"The input stream is not a valid binary format. The
starting contents (in 'bytes) are:
00-00-01-00-31-87-C7-CE-25-8A-00-00-00-33-33-33-33 ..."

I have also tried creating a com dll in visual basic 6 which extracts the
record from the file and passes it onto the equivalent structure type in vb.net.
This catches the message: "Value of type MyServer.udtProject' cannot be
converted to VBNetApp.Values.ProjectStruct"

 
My guess is that you're going to have to read the file as a series of bytes, and then use the BitConverter class to convert the ones which are numeric into the correct .net datatypes. For any string values, you'll probably need to use the ASCIIEncoding or UnicodeEncoding class to convert them into .net strings.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top