In this article, let us see how to update the Regional Settings of SharePoint Office 365 Programmatically using C# PNP.
Before proceeding to the code snippet, let us see how to do that manually.
1. Go to Site Settings
2. Select the Regional Settings.
We are going to update the Locale Dropdown to various languages.
The small piece of code is as follows.
public static void UpdateLocaleID()
{
try
{
OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, password))
{
Web web = ctx.Web;
ctx.Load(web);
#region Language settings
// Set regional settings to host web and execute the query
web.RegionalSettings.LocaleId = uint.Parse("1036");
web.RegionalSettings.Update();
ctx.ExecuteQuery();
#endregion
}
}
catch (Exception ex)
{
System.Console.WriteLine("Exception occurred : " + ex.Message);
System.Console.ReadLine();
}
}
Happy Coding,
Sathish Nadarajan.
Leave a comment