C# will not write to 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!
 
J

Jon Skeet [C# MVP]

Dean Bortell said:
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!

I suggest that instead of using a string of that form, that you encrypt
to a byte array and then use Convert.ToBase64String - that's much more
likely to be reliable.
 

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