From 932893c3a5d4827f6ce842bf3880d7bf9c147368 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 6 May 2025 16:43:12 +0200 Subject: [PATCH 1/2] Don't catch all exceptions in Directory.CreateDirectory example (#11274) --- .../CreateDirectory/dir_createdir.cs | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/snippets/csharp/System.IO/Directory/CreateDirectory/dir_createdir.cs b/snippets/csharp/System.IO/Directory/CreateDirectory/dir_createdir.cs index e1da226f48b..532054c77bd 100644 --- a/snippets/csharp/System.IO/Directory/CreateDirectory/dir_createdir.cs +++ b/snippets/csharp/System.IO/Directory/CreateDirectory/dir_createdir.cs @@ -8,29 +8,30 @@ public static void Main() { // Specify the directory you want to manipulate. string path = @"c:\MyDir"; - + + // Determine whether the directory exists. + if (Directory.Exists(path)) + { + Console.WriteLine("That path exists already."); + return; + } + + DirectoryInfo di; try { - // Determine whether the directory exists. - if (Directory.Exists(path)) - { - Console.WriteLine("That path exists already."); - return; - } - // Try to create the directory. - DirectoryInfo di = Directory.CreateDirectory(path); + di = Directory.CreateDirectory(path); Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path)); - - // Delete the directory. - di.Delete(); - Console.WriteLine("The directory was deleted successfully."); } - catch (Exception e) + catch (UnauthorizedAccessException e) { - Console.WriteLine("The process failed: {0}", e.ToString()); + Console.WriteLine("The caller does not have the required permission to create `{0}`", path); + return; } - finally {} + + // Delete the directory. + di.Delete(); + Console.WriteLine("The directory was deleted successfully."); } } -// \ No newline at end of file +// From 31531a9e5fed4e549816caab269e415ce6052fe9 Mon Sep 17 00:00:00 2001 From: pangeorg Date: Tue, 6 May 2025 19:50:04 +0200 Subject: [PATCH 2/2] Add System.ArgumentException documentation to Math.Clamp (#11276) Co-authored-by: = <=> --- xml/System/Math.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/xml/System/Math.xml b/xml/System/Math.xml index 6ee3870137c..c03edbfe4a4 100644 --- a/xml/System/Math.xml +++ b/xml/System/Math.xml @@ -1824,6 +1824,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -1880,6 +1882,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -1940,6 +1944,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if equals . To be added. + + is less than . @@ -1996,6 +2002,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -2052,6 +2060,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -2108,6 +2118,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -2181,6 +2193,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -2243,6 +2257,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -2303,6 +2319,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if equals . To be added. + + is less than . @@ -2365,6 +2383,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -2427,6 +2447,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -2489,6 +2511,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than . @@ -2568,6 +2592,8 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 if < . To be added. + + is less than .