0
我是新來的sharepoint。我試圖上傳文件並添加元數據到文件。以下是我的代碼。我可以看到一些內部的例外是他們同時宣稱ClientContext
SharePoint版本的ClientContext中的服務器版本,站點,Web引發錯誤
例外: clientContext.ServerVersion投擲型PropertyOrFieldNotInitializedException的異常
同樣是發生於網站,網頁。
using (ClientContext clientContext = new ClientContext(SPURL))
{
//ClientContext clientContext = new ClientContext(SPURL);
clientContext.Credentials = new System.Net.NetworkCredential(userName, password, domain);
Web web = clientContext.Web;
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = System.IO.File.ReadAllBytes(PPTPath);
newFile.Url = "F:\\log.txt";
List docs = web.Lists.GetByTitle("Test");
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
clientContext.ExecuteQuery();
using (FileStream fileStream =
new FileStream(PPTPath, FileMode.Open))
ClientOM.File.SaveBinaryDirect(clientContext,
DocumentRepository + PPTfilename, fileStream, true);
}