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: Change the calendar type and alternate calendar type
  27. // Reference: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.regionalsettings.calendartype.aspx
  28. RegionalSettings regSet = web.RegionalSettings;
  29. // Change the calendar type to 5 - Korean Tangun Era
  30. regSet.CalendarType = 5;
  31. regSet.AlternateCalendarType = 5;
  32. // Update the regional settings
  33. regSet.Update();
  34. clientContext.Load(regSet);
  35. // Execute the query to the server
  36. clientContext.ExecuteQuery();
  37. // Display the updated calendar type
  38. Console.WriteLine("Calendar Type: " + regSet.CalendarType + "; Alernate Calendar Type: " + regSet.AlternateCalendarType);
  39. Console.ReadLine();
  40. }
  41. }
  42. private static SecureString GetPassword()
  43. {
  44. ConsoleKeyInfo info;
  45. //Get the user's password as a SecureString
  46. SecureString securePassword = new SecureString();
  47. do
  48. {
  49. info = Console.ReadKey(true);
  50. if (info.Key != ConsoleKey.Enter)
  51. {
  52. securePassword.AppendChar(info.KeyChar);
  53. }
  54. }
  55. while (info.Key != ConsoleKey.Enter);
  56. return securePassword;
  57. }
  58. }
  59. }
Result