Hello,
I want write a data in blob attribute on Setting.
This work fine, but the data write in blob Attribute is not readable by Eb. Only by my code.
I think the problem is the encoding data.
My Code
private AttributeBlobItem AddInConfig
{
get
{
if (Item != null && addInConfig == null)
{
addInConfig = (AttributeBlobItem)Item.Attributes.FindById(AttributeId.AddinConfig);
}
return addInConfig;
}
}
public void SetData<T>(T data) where T : class
{
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings
{
Indent = true,
OmitXmlDeclaration = false,
Encoding = Encoding.Default
};
using (MemoryStream memoryStream = new MemoryStream())
using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream, xmlWriterSettings))
{
var x = new XmlSerializer(data.GetType());
x.Serialize(xmlWriter, data);
if (AddInConfig != null)
{
byte[] binaryData = memoryStream.ToArray();
AddInConfig.SetRawData(binaryData);
Item.Store();
}
}
}
This code work and the Deserialize work also.
But if access to the AttributeId.AddinConfig and call the method .ValueText() The data is not readable.
Please send me what Encoding
do you use and an example code.
I try with all Encoding in XmlWriterSettings without success.