I want to change the Site Logo of the Office 365 sandbox solution using C#.

enter image description here

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

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.