DriveInfo 클래스

정의

드라이브 정보에 액세스합니다.

public ref class DriveInfo sealed : System::Runtime::Serialization::ISerializable
public ref class DriveInfo sealed
public sealed class DriveInfo : System.Runtime.Serialization.ISerializable
public sealed class DriveInfo
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class DriveInfo : System.Runtime.Serialization.ISerializable
type DriveInfo = class
    interface ISerializable
type DriveInfo = class
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type DriveInfo = class
    interface ISerializable
Public NotInheritable Class DriveInfo
Implements ISerializable
Public NotInheritable Class DriveInfo
상속
DriveInfo
특성
구현

예제

다음 코드 예제를 사용 하는 방법을 보여 줍니다.는 DriveInfo 현재 시스템의 모든 드라이브에 대 한 정보를 표시 하는 클래스입니다.

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("  Drive 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:\
  Drive type: Removable
Drive C:\
  Drive 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:\
  Drive 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:\
  Drive type: CDRom

The actual output of this code will vary based on machine and the permissions
granted to the user executing it.
*/
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("  Drive 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:\
'  Drive type: Removable
'Drive C:\
'  Drive 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:\
'  Drive 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:\
'  Drive type: CDRom
'
'The actual output of this code will vary based on machine and the permissions
'granted to the user executing it.

설명

이 클래스는 드라이브를 모델링하고 드라이브 정보를 쿼리하는 메서드 및 속성을 제공합니다. 사용할 수 있는 드라이브와 사용 가능한 드라이브 유형을 결정하는 데 사용합니다 DriveInfo . 또한 쿼리하여 드라이브의 용량과 사용 가능한 여유 공간을 확인할 수 있습니다.

생성자

DriveInfo(String)

DriveInfo 클래스의 새 인스턴스를 만듭니다.

속성

AvailableFreeSpace

드라이브의 사용 가능한 공간(바이트)을 나타냅니다.

DriveFormat

NTFS 또는 FAT32와 같은 파일 시스템의 이름을 가져옵니다.

DriveType

CD-ROM, 이동식, 네트워크 또는 고정식 등 드라이브 형식을 가져옵니다.

IsReady

드라이브가 준비되었는지 여부를 나타내는 값을 가져옵니다.

Name

드라이브 이름(예: C:\)을 가져옵니다.

RootDirectory

드라이브의 루트 디렉터리를 가져옵니다.

TotalFreeSpace

드라이브의 사용 가능한 공간 합계(바이트)를 가져옵니다.

TotalSize

드라이브에 있는 스토리지 공간의 크기 합계(바이트)를 가져옵니다.

VolumeLabel

드라이브의 볼륨 레이블을 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetDrives()

컴퓨터에 있는 모든 논리 드라이브의 드라이브 이름을 검색합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

드라이브 이름을 문자열로 반환합니다.

명시적 인터페이스 구현

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

대상 개체를 직렬화하는 데 필요한 데이터로 SerializationInfo 개체를 채웁니다.

적용 대상