This article describes the method of C# to determine whether a specified partition is in ntfs format. Share it for your reference. The details are as follows:
using System; using ; namespace RobvanderWoude { class IsNTFS { public static int Main( string[] args ) { try { if ( == 0 ) { return WriteError( ); } if ( > 1 ) { return WriteError( "Invalid number of arguments." ); } string drive = args[0].ToUpper( ); DriveInfo[] allDrives = ( ); foreach ( DriveInfo drv in allDrives ) { if ( drive == ( 0, 2 ) ) { if ( ) { ( ( ) ); if ( == "NTFS" ) { return 0; } else { return 2; } } else { ( ( ).ToUpper( ) ); return 1; } } } return WriteError( "Invalid drive specification." ); } catch ( Exception e ) { // Display help text with error message return WriteError( e ); } } // Code to display help and optional error message, //by Bas van der Woude public static int WriteError( Exception e ) { return WriteError( e == null ? null : ); } public static int WriteError( string errorMessage ) { string fullpath = ().GetValue(0).ToString(); string[] program = ( '\\' ); string exeName = program[( 0 )]; exeName = ( 0, ( '.' ) ); if ( ( errorMessage ) == false ) { ( ); = ; ( "ERROR: " ); = ; ( errorMessage ); ( ); } ( ); ( "IsNTFS, Version 1.00" ); ( "Return 'errorlevel' 0 if the specified drive is NTFS formated" ); ( ); ( "Usage: " ); = ; ( "{0} drive:", ( ) ); ( ); ( ); ( "Note: Returns 0 if NTFS, 2 if not, 1 if not ready or invalid." ); ( ); ( "Written by Rob van der Woude" ); return 1; } } }
I hope this article will be helpful to everyone's C# programming.