C# will not write the entire string to the registry

D

Dean Bortell

I have a program that encrypts a datetime objects "to
long datetime string" string to and encrypted sequence.
The problem is this: if I use the following source code
it works (key is declared earlier and works fine):

string valueName= "Date Installed";
key.SetValue(valueName, "²ã95ì.*úÞx e¸<¡uO2s¯EÔ");

The problem is this code doesn't:

string valueName = "Date Installed";
object s1 = "²ã95ì.*úÞx e¸<¡uO2s¯EÔ";
//(I have tried string instead of object)

key.SetValue(valueName, Convert.ToString(s1));

When I check the registry in this case, only "²ã95ì.*úÞx"
was written. Please help if you can! This is driving me
crazy!
 
P

Peter Koen

I have a program that encrypts a datetime objects "to
long datetime string" string to and encrypted sequence.
The problem is this: if I use the following source code
it works (key is declared earlier and works fine):

string valueName= "Date Installed";
key.SetValue(valueName, "²ã95ì.*úÞx e¸<¡uO2s¯EÔ");

The problem is this code doesn't:

string valueName = "Date Installed";
object s1 = "²ã95ì.*úÞx e¸<¡uO2s¯EÔ";
//(I have tried string instead of object)

key.SetValue(valueName, Convert.ToString(s1));

When I check the registry in this case, only "²ã95ì.*úÞx"
was written. Please help if you can! This is driving me
crazy!

You shouldn't write encoded strings as a string into the registry. Better
write them as a byte array so that you won't have any problems with
special encodings.

To get the Bytes from the string use System.Text Namespace and the
Encoding classes.

greets
Peter

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top