Code Snippet
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Security;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Microsoft.SharePoint.Client;
  9. namespace CSOMOffice365
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. string userName = "[email protected]";
  16. Console.WriteLine("Enter your password.");
  17. SecureString password = GetPassword();
  18. // ClienContext - Get the context for the SharePoint Online Site
  19. // SharePoint site URL - https://c986.sharepoint.com
  20. using (var clientContext = new ClientContext("https://c986.sharepoint.com"))
  21. {
  22. // SharePoint Online Credentials
  23. clientContext.Credentials = new SharePointOnlineCredentials(userName, password);
  24. // Get the SharePoint web
  25. Web web = clientContext.Web;
  26. //Regional Settings: Set the locale to Hindi - 1081
  27. RegionalSettings regSet = web.RegionalSettings;
  28. regSet.LocaleId = 1081;
  29. regSet.Update();
  30. clientContext.Load(regSet);
  31. // Execute the query to the server
  32. clientContext.ExecuteQuery();
  33. // Display the updated locale ID
  34. Console.WriteLine(regSet.LocaleId);
  35. }
  36. }
  37. private static SecureString GetPassword()
  38. {
  39. ConsoleKeyInfo info;
  40. //Get the user's password as a SecureString
  41. SecureString securePassword = new SecureString();
  42. do
  43. {
  44. info = Console.ReadKey(true);
  45. if (info.Key != ConsoleKey.Enter)
  46. {
  47. securePassword.AppendChar(info.KeyChar);
  48. }
  49. }
  50. while (info.Key != ConsoleKey.Enter);
  51. return securePassword;
  52. }
  53. }
  54. }
Result