@@ -21,7 +21,8 @@ public class FileSystemUtilities
21
21
private static readonly String SPECIAL_FOLDER_PATTERN = @".*?\{.*?\}" ;
22
22
private static List < KeyValuePair < String , Environment . SpecialFolder > > SPECIAL_FOLDERS_MANUAL_MATCHMAKING ;
23
23
private static readonly List < char > INVALID_FILE_PATH_CHARACTERS ;
24
- static FileSystemUtilities ( ) {
24
+ static FileSystemUtilities ( )
25
+ {
25
26
SPECIAL_FOLDERS = new List < string > ( ) ;
26
27
SPECIAL_FOLDERS_MANUAL_MATCHMAKING = new List < KeyValuePair < string , Environment . SpecialFolder > > ( ) ;
27
28
SPECIAL_FOLDERS . AddRange ( ClassReflectionUtilities . GetEnumerableOptions ( typeof ( Environment . SpecialFolder ) ) ) ;
@@ -41,7 +42,7 @@ public static bool IsFullPathIsDirectory(String fullPath)
41
42
return true ;
42
43
}
43
44
}
44
- catch ( Exception )
45
+ catch ( Exception )
45
46
{
46
47
return false ;
47
48
}
@@ -89,11 +90,11 @@ public static DirectoryInfo[] GetDirectories(String pathName)
89
90
public static FileInfo [ ] GetFiles ( String pathName )
90
91
{
91
92
DirectoryInfo dInfo = new DirectoryInfo ( pathName ) ;
92
- FileInfo [ ] result = null ;
93
+ FileInfo [ ] result = null ;
93
94
if ( ! dInfo . Exists ) return result ;
94
95
try
95
96
{
96
- if ( FileSystemUtilities . IsDirectoryAttribute ( dInfo ) ) result = dInfo . GetFiles ( ) ;
97
+ if ( FileSystemUtilities . IsDirectoryAttribute ( dInfo ) ) result = dInfo . GetFiles ( ) ;
97
98
}
98
99
catch ( UnauthorizedAccessException ) { }
99
100
return result ;
@@ -163,7 +164,7 @@ public static String GetSpecialFolderFullPath(String fileName)
163
164
}
164
165
if ( targetEnum == null ) return null ;
165
166
166
- return System . Environment . GetFolderPath ( ( Environment . SpecialFolder ) targetEnum ) ;
167
+ return System . Environment . GetFolderPath ( ( Environment . SpecialFolder ) targetEnum ) ;
167
168
}
168
169
public static String SanitizeFileName ( String fileName )
169
170
{
@@ -227,5 +228,13 @@ public static bool IsDirectoryHasReadAndWritePermission(String directoryPath)
227
228
return false ;
228
229
}
229
230
}
231
+ public static bool isDriveReady ( String path )
232
+ {
233
+ foreach ( DriveInfo removableDrive in DriveInfo . GetDrives ( ) . Where ( d => d . IsReady ) )
234
+ {
235
+ if ( path . StartsWith ( removableDrive . RootDirectory . Name ) ) return true ;
236
+ }
237
+ return false ;
238
+ }
230
239
}
231
240
}
0 commit comments