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 time format
  27. // Reference: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.regionalsettings.time24.aspx
  28. RegionalSettings regSet = web.RegionalSettings;
  29. regSet.Time24 = true;
  30. // Update the regional settings
  31. regSet.Update();
  32. // Execute the query to the server
  33. clientContext.ExecuteQuery();
  34. }
  35. }
  36. private static SecureString GetPassword()
  37. {
  38. ConsoleKeyInfo info;
  39. //Get the user's password as a SecureString
  40. SecureString securePassword = new SecureString();
  41. do
  42. {
  43. info = Console.ReadKey(true);
  44. if (info.Key != ConsoleKey.Enter)
  45. {
  46. securePassword.AppendChar(info.KeyChar);
  47. }
  48. }
  49. while (info.Key != ConsoleKey.Enter);
  50. return securePassword;
  51. }
  52. }
  53. }
Result: