469,643 Members | 1,935 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Copying structure to string and back

Hello,

I'm trying to copy a complex structure to a string, encrypt the string, and then write the string to a file.

I've tried using the marshal class, but can't get anything to work. When I read the string in from the file, and try to copy the string to the structure to work with it, I get mangled data. Here's the string value:
"62510312006Blah11Blah 10312006123-321 dbname1 dbhost1 301FalseFalseFalseFalseFalsejbritt 032 10/30/2006 12:45:39 PM"

And the structure that I'm trying to use:

<StructLayout(LayoutKind.Sequential, pack:=0)> _
Public Structure TLIC
Dim DBID As Integer * 20
Dim CUSTNAME As String
Dim PASSWORD As Integer
Dim DISK1 As String * 9
Public dbName As String
<VBFixedString(75), System.Runtime.InteropServices.MarshalAs(System.Ru ntime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=75)> Public DBHOST As String
Dim MaxUsers As Short
Dim Nag As Short
Dim DEMO As Boolean
Dim SINGLE_Renamed As Boolean
Dim REPONLY As Boolean
Dim INSECURE As Boolean
Dim WEB As Boolean
<VBFixedString(20), System.Runtime.InteropServices.MarshalAs(System.Ru ntime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=20)> Public REPNAME As String
Dim BFUTURE1 As Byte
Dim BFUTURE2 As Byte
<VBFixedString(20), System.Runtime.InteropServices.MarshalAs(System.Ru ntime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=20)> Public SFUTURE1 As String
<VBFixedString(20), System.Runtime.InteropServices.MarshalAs(System.Ru ntime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=20)> Public SFUTURE2 As String
Dim CREATEDATE As Date
End Structure
Oct 30 '06 #1
0 894

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Martin Ho | last post: by
9 posts views Thread by Mr John FO Evans | last post: by
10 posts views Thread by Scott Townsend | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.