public File GetFileById(object id) { var key = "spointf-" + MakeId(id); var file = SharePointProviderInfoHelper.GetFile(key); if (file == null) { file = GetFile(id); if (file != null) { SharePointProviderInfoHelper.AddFile(key, file); } } return(file); }
public File CreateFile(string id, Stream stream) { byte[] b; using (var br = new BinaryReader(stream)) { b = br.ReadBytes((int)stream.Length); } var file = clientContext.Web.RootFolder.Files.Add(new FileCreationInformation { Content = b, Url = id, Overwrite = true }); clientContext.Load(file); clientContext.Load(file.ListItemAllFields); clientContext.ExecuteQuery(); SharePointProviderInfoHelper.AddFile("spointf-" + MakeId(id), file); SharePointProviderInfoHelper.PublishFolder(MakeId(GetParentFolderId(id))); return(file); }