次のようなコードを使用して適切なファイルを読み込み、データをエンコードして、適切なエンティティに付加された新しい注釈を作成することができます。あなたが何らかの理由で初期バインディングを使用している場合に、私はここでレイトバインディングを使用しました。私はあなたが乗る方法を知ってみましょう
FileStream stream = File.OpenRead("pathToFile");
byte[] byteData = new byte[stream.Length];
stream.Read(byteData, 0, byteData.Length);
stream.Close();
string encodedData = System.Convert.ToBase64String(byteData);
Entity annotation = new Entity("annotation");
annotation.Attributes["subject"] = "My subject";
annotation.Attributes["notetext"] = "My note text";
EntityReference noteRef = new EntityReference();
noteRef.LogicalName = "myEntity";
noteRef.Id = myEntity.Id;
annotation.documentbody = encodedData;
annotation.filename = "myFile.doc";
annotation.mimetype = @"application\ms-word";
annotation.Attributes.Add("objectid", noteRef);
annotation.Attributes.Add("objecttypecode", "myEntity");
service.Create(annotation);
、
感謝。
こんにちは、アノテーションクラスのdocumentbody、filename、およびmimetypeプロパティにアクセスする際にエラーが発生しています。 – skub
おそらく属性コレクションを通じてアクセスしてみてください。 annotation.Attributes ["documentbody"]。彼らは確かにそこにいるはずです。この記事では、問題の属性の設定を確認します。http://msdn.microsoft.com/en-us/library/gg328429.aspxあなたがどのように乗っているか教えてください。 –