@@ -22,7 +22,7 @@ public static class FilesFolders
22
22
/// <param name="sourcePath"></param>
23
23
/// <param name="targetPath"></param>
24
24
/// <param name="messageBoxExShow"></param>
25
- public static void CopyAll ( this string sourcePath , string targetPath , Func < string , MessageBoxResult > messageBoxExShow )
25
+ public static void CopyAll ( this string sourcePath , string targetPath , Func < string , MessageBoxResult > messageBoxExShow = null )
26
26
{
27
27
// Get the subdirectories for the specified directory.
28
28
DirectoryInfo dir = new DirectoryInfo ( sourcePath ) ;
@@ -63,6 +63,7 @@ public static void CopyAll(this string sourcePath, string targetPath, Func<strin
63
63
#if DEBUG
64
64
throw ;
65
65
#else
66
+ messageBoxExShow ??= MessageBox . Show ;
66
67
messageBoxExShow ( string . Format ( "Copying path {0} has failed, it will now be deleted for consistency" , targetPath ) ) ;
67
68
RemoveFolderIfExists ( targetPath , messageBoxExShow ) ;
68
69
#endif
@@ -78,7 +79,7 @@ public static void CopyAll(this string sourcePath, string targetPath, Func<strin
78
79
/// <param name="toPath"></param>
79
80
/// <param name="messageBoxExShow"></param>
80
81
/// <returns></returns>
81
- public static bool VerifyBothFolderFilesEqual ( this string fromPath , string toPath , Func < string , MessageBoxResult > messageBoxExShow )
82
+ public static bool VerifyBothFolderFilesEqual ( this string fromPath , string toPath , Func < string , MessageBoxResult > messageBoxExShow = null )
82
83
{
83
84
try
84
85
{
@@ -98,6 +99,7 @@ public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPat
98
99
#if DEBUG
99
100
throw ;
100
101
#else
102
+ messageBoxExShow ??= MessageBox . Show ;
101
103
messageBoxExShow ( string . Format ( "Unable to verify folders and files between {0} and {1}" , fromPath , toPath ) ) ;
102
104
return false ;
103
105
#endif
@@ -110,7 +112,7 @@ public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPat
110
112
/// </summary>
111
113
/// <param name="path"></param>
112
114
/// <param name="messageBoxExShow"></param>
113
- public static void RemoveFolderIfExists ( this string path , Func < string , MessageBoxResult > messageBoxExShow )
115
+ public static void RemoveFolderIfExists ( this string path , Func < string , MessageBoxResult > messageBoxExShow = null )
114
116
{
115
117
try
116
118
{
@@ -122,6 +124,7 @@ public static void RemoveFolderIfExists(this string path, Func<string, MessageBo
122
124
#if DEBUG
123
125
throw ;
124
126
#else
127
+ messageBoxExShow ??= MessageBox . Show ;
125
128
messageBoxExShow ( string . Format ( "Not able to delete folder {0}, please go to the location and manually delete it" , path ) ) ;
126
129
#endif
127
130
}
@@ -152,7 +155,7 @@ public static bool FileExists(this string filePath)
152
155
/// </summary>
153
156
/// <param name="fileOrFolderPath"></param>
154
157
/// <param name="messageBoxExShow"></param>
155
- public static void OpenPath ( string fileOrFolderPath , Func < string , MessageBoxResult > messageBoxExShow )
158
+ public static void OpenPath ( string fileOrFolderPath , Func < string , MessageBoxResult > messageBoxExShow = null )
156
159
{
157
160
var psi = new ProcessStartInfo
158
161
{
@@ -170,6 +173,7 @@ public static void OpenPath(string fileOrFolderPath, Func<string, MessageBoxResu
170
173
#if DEBUG
171
174
throw ;
172
175
#else
176
+ messageBoxExShow ??= MessageBox . Show ;
173
177
messageBoxExShow ( string . Format ( "Unable to open the path {0}, please check if it exists" , fileOrFolderPath ) ) ;
174
178
#endif
175
179
}
@@ -179,10 +183,10 @@ public static void OpenPath(string fileOrFolderPath, Func<string, MessageBoxResu
179
183
/// Open a file with associated application
180
184
/// </summary>
181
185
/// <param name="filePath">File path</param>
182
- /// <param name="messageBoxExShow"></param>
183
186
/// <param name="workingDir">Working directory</param>
184
187
/// <param name="asAdmin">Open as Administrator</param>
185
- public static void OpenFile ( string filePath , Func < string , MessageBoxResult > messageBoxExShow , string workingDir = "" , bool asAdmin = false )
188
+ /// <param name="messageBoxExShow"></param>
189
+ public static void OpenFile ( string filePath , string workingDir = "" , bool asAdmin = false , Func < string , MessageBoxResult > messageBoxExShow = null )
186
190
{
187
191
var psi = new ProcessStartInfo
188
192
{
@@ -201,6 +205,7 @@ public static void OpenFile(string filePath, Func<string, MessageBoxResult> mess
201
205
#if DEBUG
202
206
throw ;
203
207
#else
208
+ messageBoxExShow ??= MessageBox . Show ;
204
209
messageBoxExShow ( string . Format ( "Unable to open the path {0}, please check if it exists" , filePath ) ) ;
205
210
#endif
206
211
}
0 commit comments