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) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「DriveInfo クラス」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS