FileSystemInfo 클래스

정의

개체와 FileInfo 개체 모두 DirectoryInfo 에 대한 기본 클래스를 제공합니다.

public ref class FileSystemInfo abstract
public ref class FileSystemInfo abstract : MarshalByRefObject, System::Runtime::Serialization::ISerializable
public abstract class FileSystemInfo
public abstract class FileSystemInfo : MarshalByRefObject, System.Runtime.Serialization.ISerializable
[System.Serializable]
public abstract class FileSystemInfo : MarshalByRefObject, System.Runtime.Serialization.ISerializable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class FileSystemInfo : MarshalByRefObject, System.Runtime.Serialization.ISerializable
type FileSystemInfo = class
type FileSystemInfo = class
    inherit MarshalByRefObject
    interface ISerializable
[<System.Serializable>]
type FileSystemInfo = class
    inherit MarshalByRefObject
    interface ISerializable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type FileSystemInfo = class
    inherit MarshalByRefObject
    interface ISerializable
Public MustInherit Class FileSystemInfo
Public MustInherit Class FileSystemInfo
Inherits MarshalByRefObject
Implements ISerializable
상속
FileSystemInfo
상속
FileSystemInfo
파생
특성
구현

예제

다음 예제에서는 모든 파일 및 디렉터리를 반복하여 각 항목에 대한 일부 정보를 쿼리하는 방법을 보여 있습니다.

using System;
using System.IO;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //  Loop through all the immediate subdirectories of C.
            foreach (string entry in Directory.GetDirectories(@"C:\"))
            {
                DisplayFileSystemInfoAttributes(new DirectoryInfo(entry));
            }
            //  Loop through all the files in C.
            foreach (string entry in Directory.GetFiles(@"C:\"))
            {
                DisplayFileSystemInfoAttributes(new FileInfo(entry));
            }
        }
        static void DisplayFileSystemInfoAttributes(FileSystemInfo fsi)
        {
            //  Assume that this entry is a file.
            string entryType = "File";

            // Determine if entry is really a directory
            if ((fsi.Attributes & FileAttributes.Directory) == FileAttributes.Directory )
            {
                entryType = "Directory";
            }
            //  Show this entry's type, name, and creation date.
            Console.WriteLine("{0} entry {1} was created on {2:D}", entryType, fsi.FullName, fsi.CreationTime);
        }
    }
}

 // Output will vary based on contents of drive C.

 // Directory entry C:\Documents and Settings was created on Tuesday, November 25, 2003
 // Directory entry C:\Inetpub was created on Monday, January 12, 2004
 // Directory entry C:\Program Files was created on Tuesday, November 25, 2003
 // Directory entry C:\RECYCLER was created on Tuesday, November 25, 2003
 // Directory entry C:\System Volume Information was created on Tuesday, November 2, 2003
 // Directory entry C:\WINDOWS was created on Tuesday, November 25, 2003
 // File entry C:\IO.SYS was created on Tuesday, November 25, 2003
 // File entry C:\MSDOS.SYS was created on Tuesday, November 25, 2003
 // File entry C:\pagefile.sys was created on Saturday, December 27, 2003
Imports System.IO
Module Module1

    Sub Main()
        ' Loop through all the immediate subdirectories of C.
        For Each entry As String In Directory.GetDirectories("C:\")
            DisplayFileSystemInfoAttributes(New DirectoryInfo(entry))
        Next

        ' Loop through all the files in C.
        For Each entry As String In Directory.GetFiles("C:\")
            DisplayFileSystemInfoAttributes(New FileInfo(entry))
        Next
    End Sub

    Sub DisplayFileSystemInfoAttributes(ByVal fsi As IO.FileSystemInfo)
        ' Assume that this entry is a file.
        Dim entryType As String = "File"

        ' Determine if this entry is really a directory.
        If (fsi.Attributes And FileAttributes.Directory) = FileAttributes.Directory Then
            entryType = "Directory"
        End If

        ' Show this entry's type, name, and creation date.
        Console.WriteLine("{0} entry {1} was created on {2:D}", _
            entryType, fsi.FullName, fsi.CreationTime)
    End Sub
End Module

' Output will vary based on contents of drive C.
' 
' Directory entry C:\Documents and Settings was created on Tuesday, November 25, 2003
' Directory entry C:\Inetpub was created on Monday, January 12, 2004
' Directory entry C:\Program Files was created on Tuesday, November 25, 2003
' Directory entry C:\RECYCLER was created on Tuesday, November 25, 2003
' Directory entry C:\System Volume Information was created on Tuesday, November 2, 2003
' Directory entry C:\WINDOWS was created on Tuesday, November 25, 2003
' File entry C:\IO.SYS was created on Tuesday, November 25, 2003
' File entry C:\MSDOS.SYS was created on Tuesday, November 25, 2003
' File entry C:\pagefile.sys was created on Saturday, December 27, 2003

설명

클래스에는 FileSystemInfo 파일 및 디렉터리 조작에 공통적인 메서드가 포함되어 있습니다. 개체는 FileSystemInfo 파일 또는 디렉터리를 나타낼 수 있으므로 개체의 기초 FileInfo 역할을 합니다 DirectoryInfo . 많은 파일 및 디렉터리를 구문 분석할 때 이 기본 클래스를 사용합니다.

파생 클래스는 파생 클래스에 FileSystemInfo 열거형의 AllAccess 권한이 있는 경우에만 상속할 FileIOPermissionAccess 수 있습니다.

경로를 수락하는 멤버에서 경로는 파일 또는 디렉터리를 참조할 수 있습니다. 지정된 경로는 서버 및 공유 이름에 대한 상대 경로 또는 UNC(범용 명명 규칙) 경로를 참조할 수도 있습니다. 예를 들어 다음 모든 경로는 허용 가능한 경로입니다.

  • C#의 "c:\\MyDir\\MyFile.txt" 또는 Visual Basic의 "c:\MyDir\MyFile.txt"

  • C#의 "c:\\MyDir" 또는 Visual Basic의 "c:\MyDir"

  • C#의 "MyDir\\MySubdir" 또는 Visual Basic의 "MyDir\MySubDir"

  • C#의 "\\\\MyServer\\MyShare" 또는 Visual Basic의 "\\MyServer\MyShare"

일반적인 I/O 작업 목록은 일반적인 I/O 작업을 참조하세요.

생성자

Name Description
FileSystemInfo()

FileSystemInfo 클래스의 새 인스턴스를 초기화합니다.

FileSystemInfo(SerializationInfo, StreamingContext)
사용되지 않음.

직렬화된 데이터를 사용하여 클래스의 새 인스턴스를 FileSystemInfo 초기화합니다.

필드

Name Description
FullPath

디렉터리 또는 파일의 정규화된 경로를 나타냅니다.

OriginalPath

상대 또는 절대 경로에 관계없이 사용자가 원래 지정한 경로입니다.

속성

Name Description
Attributes

현재 파일 또는 디렉터리의 특성을 가져오거나 설정합니다.

CreationTime

현재 파일 또는 디렉터리의 생성 시간을 가져오거나 설정합니다.

CreationTimeUtc

현재 파일 또는 디렉터리의 생성 시간을 UTC(협정 세계시)로 가져오거나 설정합니다.

Exists

파일 또는 디렉터리가 있는지 여부를 나타내는 값을 가져옵니다.

Extension

전체 파일 이름인 경우에도 선행 점을 . 포함하여 파일 이름의 확장명 부분을 가져오거나 확장명 없는 경우 빈 문자열을 가져옵니다.

FullName

디렉터리 또는 파일의 전체 경로를 가져옵니다.

LastAccessTime

현재 파일 또는 디렉터리에 마지막으로 액세스한 시간을 가져오거나 설정합니다.

LastAccessTimeUtc

현재 파일 또는 디렉터리에 마지막으로 액세스한 시간(UTC)을 가져오거나 설정합니다.

LastWriteTime

현재 파일 또는 디렉터리를 마지막으로 쓴 시간을 가져오거나 설정합니다.

LastWriteTimeUtc

현재 파일 또는 디렉터리가 마지막으로 기록된 시간을 UTC(협정 세계시)로 가져오거나 설정합니다.

LinkTarget

링크의 FullName대상 경로를 가져오거나 nullFileSystemInfo 인스턴스가 링크를 나타내지 않는 경우

Name

파일의 경우 파일의 이름을 가져옵니다. 디렉터리의 경우 계층이 있는 경우 계층에서 마지막 디렉터리의 이름을 가져옵니다. 그렇지 않으면 속성은 Name 디렉터리의 이름을 가져옵니다.

UnixFileMode

현재 파일 또는 디렉터리에 대한 Unix 파일 모드를 가져오거나 설정합니다.

메서드

Name Description
CreateAsSymbolicLink(String)

지정된 FullName을 가리키는 기호 링크를 pathToTarget 만듭니다.

CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시를 생성하는 데 필요한 모든 관련 정보를 포함하는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Delete()

파일 또는 디렉터리를 삭제합니다.

Equals(Object)

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

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

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetObjectData(SerializationInfo, StreamingContext)
사용되지 않음.

SerializationInfo 파일 이름 및 추가 예외 정보를 사용하여 개체를 설정합니다.

GetType()

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

(다음에서 상속됨 Object)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

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

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

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

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Refresh()

개체의 상태를 새로 고칩니다.

ResolveLinkTarget(Boolean)

지정된 링크의 대상을 가져옵니다.

ToString()

원래 경로를 반환합니다. FullName 전체 경로 또는 파일/디렉터리 이름에 대한 속성 또는 Name 속성을 사용합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보