我能夠上傳文檔,但是當我查看/下載文檔時,似乎出現錯誤。它說它打開這個PDF時遇到了問題。 Ran into a problem從CRM上傳文檔正文到SharePoint註釋C#
我有以下代碼
using (var stream = new System.IO.MemoryStream())
{
byte[] myByte = System.Text.ASCIIEncoding.Default.GetBytes(documentBody);
foreach (byte element in myByte)
{
stream.WriteByte(element);
}
stream.Seek(0, SeekOrigin.Begin);
var newFile = new FileCreationInformation { Url = fileName, ContentStream = stream, Overwrite = true };
file = list.RootFolder.Files.Add(newFile);
file.CheckOut();
file.CheckIn(string.Empty, CheckinType.MajorCheckIn);
context.Load(file);
context.ExecuteQuery();
}
的documentBody
是場documentbody
從Annotation
(注)。 stream
有什麼問題嗎?
所以你想通過從documentBody,這是一個簡單的字符串寫入字節來創建一個PDF?如果你想創建一個PDF,它需要遵循[這裏]描述的格式(http://www.adobe.com/content/dam/Adobe/en/technology/pdfs/PDF_Day_A_Look_Inside.pdf)。 – rene
謝謝@rene,但我使用'documentbody'作爲字符串將SharePoint文檔複製到CRM Notes,我可以很好地查看它。它還適用,此外,我不是從頭創建一個PDF ... –
除了低效率,這個代碼沒有太大的錯誤。什麼是文件名?在那個文檔裏,只有純文本?但你希望返回PDF? – rene