【发布时间】:2012-06-23 08:21:22
【问题描述】:
CRM 将附件保存在 AnnotationBase 基表中。
如何将DocumentBody 实体中的文本转换回文件并将其保存到文件系统中?
我获得了documentbody 字段的值,然后尝试将其写入我的计算机,但我的文件已损坏。
我正在使用此代码:
String DocumentBody = Convert.ToBase64String(
newUnicodeEncoding().GetBytes("UEsDBBQABgAIAAAAIQDQf9XuxAEAAE4HAAATAAgCW0NvbnRlbnRfVHlwZXNd Lnh/abtPgp4eu7+W68C2dvLaWtho32sTajdkFmweGeKMQYTD5MrcDFf"));
using (FileStream fs = new FileStream("c:\\1.docx", FileMode.Create, FileAccess.Write))
{
byte[] bytes = Convert.FromBase64String(DocumentBody);
fs.Write(bytes, 0, bytes.Length);
}
GetBytes 中的字符串与 annotationBase 表中的documentbody 字段相同。
【问题讨论】:
-
不明白为什么人们已经标记了这个问题。非常中肯。
标签: c# c#-4.0 dynamics-crm dynamics-crm-2011 dynamics-crm-4