SharePoint Asked on December 31, 2021
I want to change the Site Logo of the Office 365 sandbox solution using C#.
I have tried this code:
site.RootWeb.SiteLogoUrl = imageUrl;
But, Its not working.
I also want to upload the image programmatically & store in sharepoint list (column of ‘Hyperlink & Image’ type).
For uploading file you are use below snippet
/// <summary>
/// Uploads the specified file to a SharePoint site
/// </summary>
/// <param name="url">site url</param>
/// <param name="creds">Credentials</param>
/// <param name="listTitle">List Title</param>
/// <param name="fileName">File Name</param>
private static void UploadFile(string url, ICredentials creds, string listTitle,string fileName)
{
using (var clientContext = new ClientContext(url))
{
clientContext.Credentials = creds;
using (var fs = new FileStream(fileName, FileMode.Open))
{
var fi = new FileInfo(fileName);
var list = clientContext.Web.Lists.GetByTitle(listTitle);
clientContext.Load(list.RootFolder);
clientContext.ExecuteQuery();
var fileUrl = String.Format("{0}/{1}", list.RootFolder.ServerRelativeUrl, fi.Name);
Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, fileUrl, fs, true);
}
}
}
For setting site logo you can use SiteLogoUrl
property. Its supported in CSOM https://officespdev.uservoice.com/forums/224641-general/suggestions/6234945-make-the-sitelogourl-property-available-in-csom
Answered by Amal Hashim on December 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP