我使用CSOM将文档上传到SharePoint文档库中。现在我需要使用CSOM重命名上传的文件,这是我的代码
Web web = context.Web;
bool iscontinue = false;
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = System.IO.File.ReadAllBytes(InputFileName);
newFile.Url = "/" + newFile;
List docs = web.Lists.GetByTitle(ConfigurationManager.AppSettings["DocumentLibraryName"]);
string strFilename = InputFileName;
//rename
List docs = web.Lists.GetByTitle("Shared Documents");
docs = web.Lists.GetByTitle(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryName"]));
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
context.Load(uploadFile);
context.ExecuteQuery();
ListItem item = uploadFile.ListItemAllFields;
string renamefile = txtfilename.Text.ToString();
string docTitle = string.Empty;
item["Title"] = renamefile;
item.Update();
RenameFile(context, strFilename, renamefile);