欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#判斷指定驅(qū)動(dòng)器是否是Fat分區(qū)格式的方法

 更新時(shí)間:2015年04月18日 12:39:23   作者:work24  
這篇文章主要介紹了C#判斷指定驅(qū)動(dòng)器是否是Fat分區(qū)格式的方法,涉及C#中DriveFormat屬性的使用技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了C#判斷指定驅(qū)動(dòng)器是否是Fat分區(qū)格式的方法。分享給大家供大家參考。具體如下:

using System;
using System.IO;
namespace RobvanderWoude
{
 class IsFAT
 {
  public static int Main( string[] args )
  {
   try
   {
    if ( args.Length == 0 )
    {
     return WriteError( string.Empty );
    }
    if ( args.Length > 1 )
    {
     return WriteError( "Invalid number of arguments." );
    }
    string drive = args[0].ToUpper( );
    DriveInfo[] allDrives = DriveInfo.GetDrives( );
    foreach ( DriveInfo drv in allDrives )
    {
     if ( drive == drv.Name.Substring( 0, 2 ) )
     {
      if ( drv.IsReady )
      {
       Console.WriteLine( drv.DriveFormat.ToUpper( ) );
       if (drv.DriveFormat == "FAT" || drv.DriveFormat == "FAT32")
       {
        return 0;
       }
       else
       {
        return 2;
       }
      }
      else
      {
       Console.WriteLine(drv.DriveType.ToString().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 : e.Message );
  }
  public static int WriteError( string errorMessage )
  {
   string fullpath = Environment.GetCommandLineArgs().GetValue(0).ToString();
   string[] program = fullpath.Split( '\\' );
   string exeName = program[program.GetUpperBound(0)];
   exeName = exeName.Substring(0, exeName.IndexOf('.'));
   if ( string.IsNullOrEmpty( errorMessage ) == false )
   {
    Console.Error.WriteLine();
    Console.ForegroundColor = ConsoleColor.Red;
    Console.Error.Write( "ERROR: " );
    Console.ForegroundColor = ConsoleColor.White;
    Console.Error.WriteLine( errorMessage );
    Console.ResetColor();
   }
   Console.Error.WriteLine();
   Console.Error.WriteLine("IsFAT, Version 1.00");
   Console.Error.WriteLine("Return 'errorlevel' 0 if the specified drive is FAT or FAT32 formated");
   Console.Error.WriteLine();
   Console.Error.Write("Usage: ");
   Console.ForegroundColor = ConsoleColor.White;
   Console.Error.WriteLine("{0} drive:", exeName.ToUpper());
   Console.ResetColor( );
   Console.Error.WriteLine();
   Console.Error.WriteLine("Note: Returns 0 if FAT or FAT32, 2 if not, 1 if not ready or invalid.");
   Console.Error.WriteLine();
   Console.Error.WriteLine("Written by Rob van der Woude");
   return 1;
  }
 }
}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 深入Resource實(shí)現(xiàn)多語言支持的應(yīng)用詳解

    深入Resource實(shí)現(xiàn)多語言支持的應(yīng)用詳解

    本篇文章是對(duì)Resource實(shí)現(xiàn)多語言支持的應(yīng)用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • 提取HTML代碼中文字的C#函數(shù)

    提取HTML代碼中文字的C#函數(shù)

    提取HTML代碼中文字的C#函數(shù)...
    2007-03-03
  • C#實(shí)現(xiàn)的三種模擬自動(dòng)登錄和提交POST信息的方法

    C#實(shí)現(xiàn)的三種模擬自動(dòng)登錄和提交POST信息的方法

    這篇文章主要介紹了C#實(shí)現(xiàn)的三種模擬自動(dòng)登錄和提交POST信息的方法,分別列舉了WebBrowser、WebClient及HttpWebRequest實(shí)現(xiàn)自動(dòng)登錄及提交POST的相關(guān)實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-11-11
  • C# 4.0 大數(shù)的運(yùn)算--BigInteger的應(yīng)用詳解

    C# 4.0 大數(shù)的運(yùn)算--BigInteger的應(yīng)用詳解

    本篇文章是對(duì)C# 4.0 大數(shù)的運(yùn)算 BigInteger的應(yīng)用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • C# 8.0可空引用類型的使用注意記錄

    C# 8.0可空引用類型的使用注意記錄

    這篇文章主要給大家介紹了關(guān)于C# 8.0可空引用類型使用注意的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用C#具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • C#定義的MP3播放類實(shí)例

    C#定義的MP3播放類實(shí)例

    這篇文章主要介紹了C#定義的MP3播放類,實(shí)例分析了C#操作多媒體音頻文件的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-04-04
  • C# 中DateTime 的使用技巧匯總

    C# 中DateTime 的使用技巧匯總

    本文主要介紹了DateTime的使用技巧,包括獲取本周、上周、下周、本月、上個(gè)月、下個(gè)月、本季度、上季度、下季度、本年度、上年度、下年度等多個(gè)方法,分享給大家,希望對(duì)大家有所幫助。
    2016-04-04
  • Visual Studio C#創(chuàng)建windows服務(wù)程序

    Visual Studio C#創(chuàng)建windows服務(wù)程序

    用Visual C#創(chuàng)建Windows服務(wù)不是一件困難的事,本文就將指導(dǎo)你一步一步創(chuàng)建一個(gè)Windows服務(wù)并使用它,本文主要介紹了Visual Studio C#創(chuàng)建windows服務(wù)程序,感興趣的可以了解一下
    2024-01-01
  • C#中標(biāo)準(zhǔn)的IDispose模式代碼詳解

    C#中標(biāo)準(zhǔn)的IDispose模式代碼詳解

    在本篇文章中小編給大家分享的是關(guān)于C#中標(biāo)準(zhǔn)的IDispose模式的實(shí)例用法相關(guān)內(nèi)容,有需要的朋友們測(cè)試下。
    2019-09-09
  • C#線程倒計(jì)時(shí)器源碼分享

    C#線程倒計(jì)時(shí)器源碼分享

    這篇文章主要為大家分享了C#線程倒計(jì)時(shí)器源碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-01-01

最新評(píng)論