FileSystemInfo 클래스

정의

FileInfoDirectoryInfo 개체에 대한 기본 클래스를 제공합니다.

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 namespace System;
using namespace System::IO;


namespace ConsoleApplication2
{
    public ref class Program
    {
    public:
        static void Main()
        {
            //  Loop through all the immediate subdirectories of C.
            for each (String^ entry in Directory::GetDirectories("C:\\"))
            {
                DisplayFileSystemInfoAttributes(gcnew DirectoryInfo(entry));
            }
            //  Loop through all the files in C.
            for each (String^ entry in Directory::GetFiles("C:\\"))
            {
                DisplayFileSystemInfoAttributes(gcnew 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);
        }
    };
};

int main()
{
    ConsoleApplication2::Program::Main();
}

 // 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
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 작업을 참조하세요.

생성자

FileSystemInfo()

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

FileSystemInfo(SerializationInfo, StreamingContext)

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

필드

FullPath

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

OriginalPath

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

속성

Attributes

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

CreationTime

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

CreationTimeUtc

현재 파일 또는 디렉터리를 만든 시간을 UTC(협정 세계시) 기준으로 가져오거나 설정합니다.

Exists

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

Extension

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

FullName

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

LastAccessTime

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

LastAccessTimeUtc

현재 파일이나 디렉터리를 마지막으로 액세스한 시간을 UTC 기준으로 가져오거나 설정합니다.

LastWriteTime

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

LastWriteTimeUtc

현재 파일이나 디렉터리에 마지막으로 쓴 시간을 UTC 기준으로 가져오거나 설정합니다.

LinkTarget

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

Name

파일의 경우 파일 이름을 가져옵니다. 디렉터리의 경우 계층이 있으면 계층에 있는 마지막 디렉터리의 이름을 가져오고, 계층이 없으면 Name 속성이 디렉터리 이름을 가져옵니다.

UnixFileMode

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

메서드

CreateAsSymbolicLink(String)

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

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)

적용 대상

추가 정보