473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 1025

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

Similar topics

10
by: Cocy | last post by:
Hi, This might be a sort of FAQ, but I don't see why, so I would someone help me to understand what's wrong? I've just created following code which wold trim white space(s) in a (given) string....
2
by: vikas | last post by:
I have following structure in c++. typedef struct MMF_result_struct { int action; char text; int cols,rows; int month,day,year; } MMF_result; Now this structure is shared between C++ and C#...
4
by: Scott Lemen | last post by:
Hi, Some Win APIs expect a structure with a fixed length string. How is it defined in VB .Net 2003? When I try to use the FixedLengthString class I get an "Array bounds cannot appear in type...
10
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in...
0
by: kagorami | last post by:
Q: How do you return a LPSTR from unmanaged code? A: Use a StringBuilder. What about this: public struct CSTRUCT { string return_value; } How do you get a LPSTR from unmanaged code when it...
9
by: Mr John FO Evans | last post by:
Am looking at adding structures to an embedded C emulator but am wondering what the standard is for copying structures(ie structa=structb) which contain pointers to memory and which are therefore...
5
by: mark_aok | last post by:
Hi all, I have a situation where I have a split database. At the back end, I need to - create a new table (I will call it newTable) with the exact fields, and relationships as another table...
5
by: zehra.mb | last post by:
Hi, I had written application for storing employee data in binary file and reading those data from binary file and display it in C language. But I face some issue with writing data to binary file....
10
by: Scott Townsend | last post by:
So I need to talk to a devices that expects all of the bits and bytes I sent it to be in specific places (not yet 100% defined). I wanted to create a structure/class with all of the data in it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.