schubduese
asked on
Write Binary Data into XML with Linq
I read some values of the registry and write them to a XML with Linq. Some Values have binary characters and look like this:
ήì\ÎQÝÜ$Ñ.Ì6Å·xxµ0© ÐQfô:S9}:& amp;X¨Pܾ ×CPkÑ
The program crashes when I try to write those values into the XML. How can I write these values into the xml?
ήì\ÎQÝÜ$Ñ.Ì6Å·xxµ0©
The program crashes when I try to write those values into the XML. How can I write these values into the xml?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Could you give me a C# example?
Do I have to check every reg entry I read for bin values?
Do I have to check every reg entry I read for bin values?
ASKER
I can write the Data Base64 Encoded with this:
public static string Encode(string str)
{
byte[] encbuff = System.Text.Encoding.UTF8. GetBytes(s tr);
return Convert.ToBase64String(enc buff);
}
That means the routine wich Shows the XML in the Application needs this routine:
public string Decode(string str)
{
byte[] decbuff = Convert.FromBase64String(s tr);
return System.Text.Encoding.UTF8. GetString( decbuff);
}
right?
That means writing the binary into the XML as it is, doesn't work?
public static string Encode(string str)
{
byte[] encbuff = System.Text.Encoding.UTF8.
return Convert.ToBase64String(enc
}
That means the routine wich Shows the XML in the Application needs this routine:
public string Decode(string str)
{
byte[] decbuff = Convert.FromBase64String(s
return System.Text.Encoding.UTF8.
}
right?
That means writing the binary into the XML as it is, doesn't work?
ASKER
There we go with the next Error Message
The Key which failed, works now. But if I scan HKLM\Software\Windows\Curr entVersion it fails and says that the binary value (hex code 0xFFFF) is not a valid sign!
Any help on this?
The Key which failed, works now. But if I scan HKLM\Software\Windows\Curr
Any help on this?
I use one of the components in IP!Works (www.nsoftware.com) to do MIME encodings. If you want to uuencode it instead, there is code here http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=351