FileSystemInfo FileSystemInfo FileSystemInfo FileSystemInfo Class

정의

FileInfoDirectoryInfo 개체에 대한 기본 클래스를 제공합니다.Provides the base class for both FileInfo and DirectoryInfo objects.

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

예제

다음 예제에서는 모든 파일 및 디렉터리를 쿼리 하는 각 항목에 대 한 정보를 반복 하는 방법을 보여 줍니다.The following example shows how to loop through all the files and directories, querying some information about each entry.

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 클래스에 파일과 디렉터리 조작에 공통 되는 메서드가 포함 되어 있습니다.The FileSystemInfo class contains methods that are common to file and directory manipulation. A FileSystemInfo 개체는 파일 또는 디렉터리를 기준으로 제공 되므로 나타낼 수 있습니다 FileInfo 또는 DirectoryInfo 개체입니다.A FileSystemInfo object can represent either a file or a directory, thus serving as the basis for FileInfo or DirectoryInfo objects. 많은 파일 및 디렉터리를 구문 분석할 때이 기본 클래스를 사용 합니다.Use this base class when parsing a lot of files and directories.

파생된 클래스에서 상속할 수 있습니다 FileSystemInfo 파생된 클래스에서 AllAccess 권한을 가진 경우에는 FileIOPermissionAccess 열거형입니다.A derived class can inherit from FileSystemInfo only if the derived class has the AllAccess permission from the FileIOPermissionAccess enumeration.

경로 허용 하는 멤버의 경로 파일 또는 디렉터리를 참조할 수 있습니다.In members that accept a path, the path can refer to a file or just a directory. 지정된 된 경로 상대 경로 또는 서버 및 공유 이름에 대 한 범용 명명 규칙 (UNC) 경로 참조할 수 있습니다.The specified path can also refer to a relative path or a Universal Naming Convention (UNC) path for a server and share name. 예를 들어, 다음은 허용 가능한 경로.For example, all the following are acceptable paths:

  • "c:\\MyDir\\MyFile.txt" C# 또는 Visual Basic의 "c:\MyDir\MyFile.txt"입니다."c:\\MyDir\\MyFile.txt" in C#, or "c:\MyDir\MyFile.txt" in Visual Basic.

  • "c:\\MyDir" C# 또는 Visual Basic의 "c:\MyDir"입니다."c:\\MyDir" in C#, or "c:\MyDir" in Visual Basic.

  • "MyDir\\MySubdir" C# 또는 Visual Basic의 "MyDir\MySubDir"입니다."MyDir\\MySubdir" in C#, or "MyDir\MySubDir" in Visual Basic.

  • "\\\\MyServer\\MyShare" C#에서 또는 "\\MyServer\MyShare" Visual Basic의 합니다."\\\\MyServer\\MyShare" in C#, or "\\MyServer\MyShare" in Visual Basic.

공통적인 I/O 작업의 목록을 참조 하세요 공통적인 I/O 작업합니다.For a list of common I/O tasks, see Common I/O Tasks.

생성자

FileSystemInfo() FileSystemInfo() FileSystemInfo() FileSystemInfo()

FileSystemInfo 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the FileSystemInfo class.

FileSystemInfo(SerializationInfo, StreamingContext) FileSystemInfo(SerializationInfo, StreamingContext) FileSystemInfo(SerializationInfo, StreamingContext) FileSystemInfo(SerializationInfo, StreamingContext)

serialize된 데이터를 사용하여 FileSystemInfo 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the FileSystemInfo class with serialized data.

필드

FullPath FullPath FullPath FullPath

파일이나 디렉터리의 정규화된 경로를 나타냅니다.Represents the fully qualified path of the directory or file.

OriginalPath OriginalPath OriginalPath OriginalPath

사용자가 원래 지정한 상대 또는 절대 경로입니다.The path originally specified by the user, whether relative or absolute.

속성

Attributes Attributes Attributes Attributes

현재 파일 또는 디렉터리의 특성을 가져오거나 설정합니다.Gets or sets the attributes for the current file or directory.

CreationTime CreationTime CreationTime CreationTime

현재 파일 또는 디렉터리를 만든 시간을 가져오거나 설정합니다.Gets or sets the creation time of the current file or directory.

CreationTimeUtc CreationTimeUtc CreationTimeUtc CreationTimeUtc

현재 파일 또는 디렉터리를 만든 시간을 UTC(협정 세계시) 기준으로 가져오거나 설정합니다.Gets or sets the creation time, in coordinated universal time (UTC), of the current file or directory.

Exists Exists Exists Exists

파일이나 디렉터리가 있는지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether the file or directory exists.

Extension Extension Extension Extension

파일의 확장명 부분을 나타내는 문자열을 가져옵니다.Gets the string representing the extension part of the file.

FullName FullName FullName FullName

파일이나 디렉터리의 전체 경로를 가져옵니다.Gets the full path of the directory or file.

LastAccessTime LastAccessTime LastAccessTime LastAccessTime

현재 파일이나 디렉터리에 마지막으로 액세스한 시간을 가져오거나 설정합니다.Gets or sets the time the current file or directory was last accessed.

LastAccessTimeUtc LastAccessTimeUtc LastAccessTimeUtc LastAccessTimeUtc

현재 파일이나 디렉터리를 마지막으로 액세스한 시간을 UTC 기준으로 가져오거나 설정합니다.Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed.

LastWriteTime LastWriteTime LastWriteTime LastWriteTime

현재 파일이나 디렉터리에 마지막으로 쓴 시간을 가져오거나 설정합니다.Gets or sets the time when the current file or directory was last written to.

LastWriteTimeUtc LastWriteTimeUtc LastWriteTimeUtc LastWriteTimeUtc

현재 파일이나 디렉터리에 마지막으로 쓴 시간을 UTC 기준으로 가져오거나 설정합니다.Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to.

Name Name Name Name

파일의 경우 파일 이름을 가져옵니다.For files, gets the name of the file. 디렉터리의 경우 계층이 있으면 계층에 있는 마지막 디렉터리의 이름을 가져오고,For directories, gets the name of the last directory in the hierarchy if a hierarchy exists. 계층이 없으면 Name 속성이 디렉터리 이름을 가져옵니다.Otherwise, the Name property gets the name of the directory.

메서드

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Delete() Delete() Delete() Delete()

파일이나 디렉터리를 삭제합니다.Deletes a file or directory.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

파일 이름 및 추가 예외 정보를 사용하여 SerializationInfo 개체를 설정합니다.Sets the SerializationInfo object with the file name and additional exception information.

GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
Refresh() Refresh() Refresh() Refresh()

개체의 상태를 새로 고칩니다.Refreshes the state of the object.

ToString() ToString() ToString() ToString()

원래 경로를 반환합니다.Returns the original path. 전체 경로 또는 파일/디렉터리 이름의 FullName 또는 Name 속성을 사용합니다.Use the FullName or Name properties for the full path or file/directory name.

보안

FileIOPermission
이 클래스에서 상속 하는 데 필요한 권한입니다.for permission to inherit from this class. 연결 된 열거형: UnrestrictedAssociated enumeration: Unrestricted 보안 동작: 상속 요구Security Action: Inheritance Demand

적용 대상

추가 정보