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).

1 Answer 1


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);
               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

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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