@@ -21,7 +21,8 @@ public class FileSystemUtilities
2121 private static readonly String SPECIAL_FOLDER_PATTERN = @".*?\{.*?\}" ;
2222 private static List < KeyValuePair < String , Environment . SpecialFolder > > SPECIAL_FOLDERS_MANUAL_MATCHMAKING ;
2323 private static readonly List < char > INVALID_FILE_PATH_CHARACTERS ;
24- static FileSystemUtilities ( ) {
24+ static FileSystemUtilities ( )
25+ {
2526 SPECIAL_FOLDERS = new List < string > ( ) ;
2627 SPECIAL_FOLDERS_MANUAL_MATCHMAKING = new List < KeyValuePair < string , Environment . SpecialFolder > > ( ) ;
2728 SPECIAL_FOLDERS . AddRange ( ClassReflectionUtilities . GetEnumerableOptions ( typeof ( Environment . SpecialFolder ) ) ) ;
@@ -41,7 +42,7 @@ public static bool IsFullPathIsDirectory(String fullPath)
4142 return true ;
4243 }
4344 }
44- catch ( Exception )
45+ catch ( Exception )
4546 {
4647 return false ;
4748 }
@@ -89,11 +90,11 @@ public static DirectoryInfo[] GetDirectories(String pathName)
8990 public static FileInfo [ ] GetFiles ( String pathName )
9091 {
9192 DirectoryInfo dInfo = new DirectoryInfo ( pathName ) ;
92- FileInfo [ ] result = null ;
93+ FileInfo [ ] result = null ;
9394 if ( ! dInfo . Exists ) return result ;
9495 try
9596 {
96- if ( FileSystemUtilities . IsDirectoryAttribute ( dInfo ) ) result = dInfo . GetFiles ( ) ;
97+ if ( FileSystemUtilities . IsDirectoryAttribute ( dInfo ) ) result = dInfo . GetFiles ( ) ;
9798 }
9899 catch ( UnauthorizedAccessException ) { }
99100 return result ;
@@ -163,7 +164,7 @@ public static String GetSpecialFolderFullPath(String fileName)
163164 }
164165 if ( targetEnum == null ) return null ;
165166
166- return System . Environment . GetFolderPath ( ( Environment . SpecialFolder ) targetEnum ) ;
167+ return System . Environment . GetFolderPath ( ( Environment . SpecialFolder ) targetEnum ) ;
167168 }
168169 public static String SanitizeFileName ( String fileName )
169170 {
@@ -227,5 +228,13 @@ public static bool IsDirectoryHasReadAndWritePermission(String directoryPath)
227228 return false ;
228229 }
229230 }
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+ }
230239 }
231240}
0 commit comments