none
Decoding the encoded string is not getting the special characters correctly RRS feed

  • Question

  • Hi,

    I am using the below code to encode the content of *.ser file

    foreach (string file in Directory.EnumerateFiles("", "*.SER")) { byte[] content = File.ReadAllBytes( file ); xmlWriter.WriteStartElement("SerializedFile"); xmlWriter.WriteElementString("FileName", Path.GetFileName(file)); xmlWriter.WriteElementString("Content", System.Convert.ToBase64String( content ) ); xmlWriter.WriteEndElement(); }

    Now i have to decode the encoded content and create *.ser file, i tried with below code but the size of original *.ser file and generated *.ser file after i decode differs and if i check the content i can see some difference with the special characters.

    encodedContent = xmlnode[i].ChildNodes.Item(1).InnerText;
                    byte[] data = Convert.FromBase64String(encodedContent);
                    string decodedContent = Encoding.UTF8.GetString(data);

    Please help me out to solve this issue. Thanks in advance.

    Regards,

    Chetan.


    Chetan Rajakumar

    Wednesday, October 29, 2014 1:56 PM

Answers

All replies

  • In order to re-create the file, try this:

        File.WriteAllBytes( filename, data );

    Wednesday, October 29, 2014 9:10 PM
  • Hello Chetan,

    Any update? I have marked Viorels reply as answer since I think it is helpful, if you think it provides no help, please unmark it.

    Thank you for your understanding and support.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 7, 2014 8:19 AM
    Moderator