我正在上传文件到sharepoint ..但是我想提供一个自定义名称,而不是它继承了即时上传文件的名称。更新listitem属性不提交更改为共享点
我的代码是基于这样的解决方案:http://www.codeproject.com/Articles/103503/How-to-upload-download-a-document-in-SharePoint-20.aspx
但是这并不工作。
另外,我也想提供该文件的标题: ,所以我想更新标题:
uploadFile.ListItemAllFields.FieldValues["Title"] = "my custom title";
然而,一旦该文件已完成其upload..i登录SharePoint和注意标题没有被应用。
我该如何整合上传文件和应用新名称?
千恩万谢,
编辑:
using (var clientContext = GetNewContext())
{
var uploadLocation = string.Format("{0}{1}/{2}", SiteUrl, Helpers.ListNames.RequestedDocuments, Path.GetFileName(document));
//Get Document List
var documentslist = clientContext.Web.Lists.GetByTitle(Helpers.ListNames.RequestedDocuments);
var fileCreationInformation = new FileCreationInformation
{
Content = System.IO.File.ReadAllBytes(document), //Assign to content byte[] i.e. documentStream
Overwrite = true, //Allow owerwrite of document
Url = uploadLocation //Upload URL,
};
var uploadFile = documentslist.RootFolder.Files.Add(fileCreationInformation);
uploadFile.ListItemAllFields.FieldValues["Title"] = title;
uploadFile.ListItemAllFields.Update();
clientContext.ExecuteQuery();
}
site.SubmitChanges(ConflictMode.FailOnFirstConflict, true);
是,看到更新的问题 – nologo 2011-06-01 13:27:01