DriveInfoとは? わかりやすく解説

DriveInfo クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

ドライブに関する情報へのアクセス提供します

名前空間: System.IO
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 DriveInfo
    Implements ISerializable
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public sealed class DriveInfo : ISerializable
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class DriveInfo sealed : ISerializable
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class DriveInfo implements ISerializable
SerializableAttribute 
ComVisibleAttribute(true) 
public final class DriveInfo implements ISerializable
解説解説
使用例使用例

DriveInfo クラス使用して現在のシステムの全ドライブに関する情報表示する方法次のコード例示します

Imports System
Imports System.IO

Class Test
    Public Shared Sub Main()
        Dim allDrives() As DriveInfo = DriveInfo.GetDrives()

        Dim d As DriveInfo
        For Each d In allDrives
            Console.WriteLine("Drive {0}", d.Name)
            Console.WriteLine("  File type: {0}",
 d.DriveType)
            If d.IsReady = True Then
                Console.WriteLine("  Volume label: {0}",
 d.VolumeLabel)
                Console.WriteLine("  File system: {0}",
 d.DriveFormat)
                Console.WriteLine( _
                    "  Available space to current user:{0, 15}
 bytes", _
                    d.AvailableFreeSpace)

                Console.WriteLine( _
                    "  Total available space:          {0, 15}
 bytes", _
                    d.TotalFreeSpace)

                Console.WriteLine( _
                    "  Total size of drive:            {0, 15}
 bytes ", _
                    d.TotalSize)
            End If
        Next
    End Sub
End Class
'This code produces output similar to the following:
'
'Drive A:\
'  File type: Removable
'Drive C:\
'  File type: Fixed
'  Volume label: 
'  File system: FAT32
'  Available space to current user:     4770430976 bytes
'  Total available space:               4770430976 bytes
'  Total size of drive:                10731683840 bytes 
'Drive D:\
'  File type: Fixed
'  Volume label: 
'  File system: NTFS
'  Available space to current user:    15114977280 bytes
'  Total available space:              15114977280 bytes
'  Total size of drive:                25958948864 bytes 
'Drive E:\
'  File type: CDRom
'
'The actual output of this code will vary based on machine and the permissions
'granted to the user executing it.
using System;
using System.IO;

class Test
{
    public static void Main()
    {
        DriveInfo[] allDrives = DriveInfo.GetDrives();

        foreach (DriveInfo d in allDrives)
        {
            Console.WriteLine("Drive {0}", d.Name);
            Console.WriteLine("  File type: {0}", d.DriveType);
            if (d.IsReady == true)
            {
                Console.WriteLine("  Volume label: {0}", d.VolumeLabel);
                Console.WriteLine("  File system: {0}", d.DriveFormat);
                Console.WriteLine(
                    "  Available space to current user:{0, 15} bytes",
 
                    d.AvailableFreeSpace);

                Console.WriteLine(
                    "  Total available space:          {0, 15} bytes",
                    d.TotalFreeSpace);

                Console.WriteLine(
                    "  Total size of drive:            {0, 15} bytes "
,
                    d.TotalSize);
            }
        }
    }
}
/* 
This code produces output similar to the following:

Drive A:\
  File type: Removable
Drive C:\
  File type: Fixed
  Volume label: 
  File system: FAT32
  Available space to current user:     4770430976 bytes
  Total available space:               4770430976 bytes
  Total size of drive:                10731683840 bytes 
Drive D:\
  File type: Fixed
  Volume label: 
  File system: NTFS
  Available space to current user:    15114977280 bytes
  Total available space:              15114977280 bytes
  Total size of drive:                25958948864 bytes 
Drive E:\
  File type: CDRom

The actual output of this code will vary based on machine and
 the permissions
granted to the user executing it.
*/
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.IO.DriveInfo
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DriveInfo コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定したドライブに関する情報へのアクセス提供します

名前空間: System.IO
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    driveName As String _
)
Dim driveName As String

Dim instance As New DriveInfo(driveName)
public DriveInfo (
    string driveName
)
public:
DriveInfo (
    String^ driveName
)
public DriveInfo (
    String driveName
)
public function DriveInfo (
    driveName : String
)

パラメータ

driveName

有効なドライブ パスまたはドライブ名大文字または小文字の 'a' ~ 'z' を使用できますnull 値使用できません。

例外例外
例外種類条件

ArgumentNullException

ドライブ名null 参照 (Visual Basic では Nothing) にすることはできません。

ArgumentException

driveName最初文字が、大文字または小文字の 'a' ~ 'z' ではありません。

解説解説

ドライブに関する情報取得するには、このクラス使用しますドライブ名は、'a' ~ 'z' の範囲大文字または小文字にする必要がありますnull 参照 (Visual Basic では Nothing) のドライブ名に関する情報取得、または UNC (\\server\share) パス使用するためにこのメソッド使用することはできません。

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DriveInfo プロパティ


DriveInfo メソッド


DriveInfo メンバ

ドライブに関する情報へのアクセス提供します

DriveInfo データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Runtime.Serialization.ISerializable.GetObjectData SerializationInfo オブジェクトに、オブジェクトシリアル化するために必要なデータ設定します
参照参照

関連項目

DriveInfo クラス
System.IO 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DriveInfo」の関連用語

DriveInfoのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DriveInfoのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS