Directory.GetFileSystemEntries 메서드

정의

지정된 조건을 충족하는 모든 파일 및 하위 디렉터리 이름을 반환합니다.

오버로드

GetFileSystemEntries(String)

지정된 경로에 있는 모든 파일과 하위 디렉터리의 이름을 반환합니다.

GetFileSystemEntries(String, String)

지정된 경로에서 검색 패턴과 일치하는 파일 및 디렉터리 이름 배열을 반환합니다.

GetFileSystemEntries(String, String, EnumerationOptions)

지정된 경로에서 검색 패턴 및 열거형 옵션과 일치하는 파일 이름 및 디렉터리 이름의 배열을 반환합니다.

GetFileSystemEntries(String, String, SearchOption)

지정된 경로에서 검색 패턴과 일치하는 모든 파일 이름 및 디렉터리 이름의 배열을 가져오고 선택적으로 하위 디렉터리를 반환합니다.

GetFileSystemEntries(String)

Source:
Directory.cs
Source:
Directory.cs
Source:
Directory.cs

지정된 경로에 있는 모든 파일과 하위 디렉터리의 이름을 반환합니다.

public:
 static cli::array <System::String ^> ^ GetFileSystemEntries(System::String ^ path);
public static string[] GetFileSystemEntries (string path);
static member GetFileSystemEntries : string -> string[]
Public Shared Function GetFileSystemEntries (path As String) As String()

매개 변수

path
String

검색할 디렉터리에 대한 상대 또는 절대 경로입니다. 이 문자열은 대/소문자를 구분하지 않습니다.

반환

String[]

지정된 디렉터리에서 파일 및 하위 디렉터리 이름의 배열이거나 파일 또는 디렉터리가 없으면 빈 배열입니다.

예외

호출자에게 필요한 권한이 없는 경우

2.1보다 오래된 .NET Framework 및 .NET Core 버전: path 길이가 0인 문자열이거나, 공백만 포함하거나, 하나 이상의 잘못된 문자를 포함합니다. GetInvalidPathChars()를 사용하여 잘못된 문자를 쿼리할 수 있습니다.

path이(가) null인 경우

지정된 경로, 파일 이름 또는 둘 다가 시스템에서 정의한 최대 길이를 초과합니다.

path는 파일 이름입니다.

지정된 경로가 잘못되었습니다(예: 매핑되지 않은 드라이브에 있음).

예제

다음 예제에서는 메서드를 GetFileSystemEntries 사용하여 문자열 배열을 사용자가 지정한 위치에 있는 모든 파일 및 하위 디렉터리의 이름으로 채우고 배열의 각 문자열을 콘솔에 출력합니다. 이 예제는 이 메서드에 공통된 모든 오류를 catch하도록 구성됩니다.

using namespace System;
class Class1
{
public:
   void PrintFileSystemEntries( String^ path )
   {
      try
      {
         
         // Obtain the file system entries in the directory path.
         array<String^>^directoryEntries = System::IO::Directory::GetFileSystemEntries( path );
         for ( int i = 0; i < directoryEntries->Length; i++ )
         {
            System::Console::WriteLine( directoryEntries[ i ] );

         }
      }
      catch ( ArgumentNullException^ ) 
      {
         System::Console::WriteLine(  "Path is a null reference." );
      }
      catch ( System::Security::SecurityException^ ) 
      {
         System::Console::WriteLine(  "The caller does not have the \HelloServer'                  required permission." );
      }
      catch ( ArgumentException^ ) 
      {
         System::Console::WriteLine(  "Path is an empty String, \HelloServer'                  contains only white spaces, \HelloServer'                  or contains invalid characters." );
      }
      catch ( System::IO::DirectoryNotFoundException^ ) 
      {
         System::Console::WriteLine(  "The path encapsulated in the \HelloServer'                  Directory object does not exist." );
      }

   }

   void PrintFileSystemEntries( String^ path, String^ pattern )
   {
      try
      {
         
         // Obtain the file system entries in the directory
         // path that match the pattern.
         array<String^>^directoryEntries = System::IO::Directory::GetFileSystemEntries( path, pattern );
         for ( int i = 0; i < directoryEntries->Length; i++ )
         {
            System::Console::WriteLine( directoryEntries[ i ] );

         }
      }
      catch ( ArgumentNullException^ ) 
      {
         System::Console::WriteLine(  "Path is a null reference." );
      }
      catch ( System::Security::SecurityException^ ) 
      {
         System::Console::WriteLine(  "The caller does not have the \HelloServer'                  required permission." );
      }
      catch ( ArgumentException^ ) 
      {
         System::Console::WriteLine(  "Path is an empty String, \HelloServer'                  contains only white spaces, \HelloServer'                  or contains invalid characters." );
      }
      catch ( System::IO::DirectoryNotFoundException^ ) 
      {
         System::Console::WriteLine(  "The path encapsulated in the \HelloServer'                  Directory object does not exist." );
      }

   }


   // Print out all logical drives on the system.
   void GetLogicalDrives()
   {
      try
      {
         array<String^>^drives = System::IO::Directory::GetLogicalDrives();
         for ( int i = 0; i < drives->Length; i++ )
         {
            System::Console::WriteLine( drives[ i ] );

         }
      }
      catch ( System::IO::IOException^ ) 
      {
         System::Console::WriteLine(  "An I/O error occurs." );
      }
      catch ( System::Security::SecurityException^ ) 
      {
         System::Console::WriteLine(  "The caller does not have the \HelloServer'                  required permission." );
      }

   }

   void GetParent( String^ path )
   {
      try
      {
         System::IO::DirectoryInfo^ directoryInfo = System::IO::Directory::GetParent( path );
         System::Console::WriteLine( directoryInfo->FullName );
      }
      catch ( ArgumentNullException^ ) 
      {
         System::Console::WriteLine(  "Path is a null reference." );
      }
      catch ( ArgumentException^ ) 
      {
         System::Console::WriteLine(  "Path is an empty String, \HelloServer'                  contains only white spaces, or \HelloServer'                  contains invalid characters." );
      }

   }

   void Move( String^ sourcePath, String^ destinationPath )
   {
      try
      {
         System::IO::Directory::Move( sourcePath, destinationPath );
         System::Console::WriteLine(  "The directory move is complete." );
      }
      catch ( ArgumentNullException^ ) 
      {
         System::Console::WriteLine(  "Path is a null reference." );
      }
      catch ( System::Security::SecurityException^ ) 
      {
         System::Console::WriteLine(  "The caller does not have the \HelloServer'                  required permission." );
      }
      catch ( ArgumentException^ ) 
      {
         System::Console::WriteLine(  "Path is an empty String, \HelloServer'                  contains only white spaces, \HelloServer'                  or contains invalid characters." );
      }
      catch ( System::IO::IOException^ ) 
      {
         System::Console::WriteLine(  "An attempt was made to move a \HelloServer'                  directory to a different \HelloServer'                  volume, or destDirName \HelloServer'                  already exists." );
      }

   }

};

int main()
{
   Class1 * snippets = new Class1;
   String^ path = System::IO::Directory::GetCurrentDirectory();
   String^ filter =  "*.exe";
   snippets->PrintFileSystemEntries( path );
   snippets->PrintFileSystemEntries( path, filter );
   snippets->GetLogicalDrives();
   snippets->GetParent( path );
   snippets->Move(  "C:\\proof",  "C:\\Temp" );
   return 0;
}
using System;

namespace GetFileSystemEntries
{
    class Class1
    {
        static void Main(string[] args)
        {
            Class1 snippets = new Class1();

            string path = System.IO.Directory.GetCurrentDirectory();
            string filter = "*.exe";

            snippets.PrintFileSystemEntries(path);
            snippets.PrintFileSystemEntries(path, filter);		
            snippets.GetLogicalDrives();
            snippets.GetParent(path);
            snippets.Move("C:\\proof", "C:\\Temp");
        }

        void PrintFileSystemEntries(string path)
        {
            
            try
            {
                // Obtain the file system entries in the directory path.
                string[] directoryEntries =
                    System.IO.Directory.GetFileSystemEntries(path);

                foreach (string str in directoryEntries)
                {
                    System.Console.WriteLine(str);
                }
            }
            catch (ArgumentNullException)
            {
                System.Console.WriteLine("Path is a null reference.");
            }
            catch (System.Security.SecurityException)
            {
                System.Console.WriteLine("The caller does not have the " +
                    "required permission.");
            }
            catch (ArgumentException)
            {
                System.Console.WriteLine("Path is an empty string, " +
                    "contains only white spaces, " +
                    "or contains invalid characters.");
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                System.Console.WriteLine("The path encapsulated in the " +
                    "Directory object does not exist.");
            }
        }
        void PrintFileSystemEntries(string path, string pattern)
        {
            try
            {
                // Obtain the file system entries in the directory
                // path that match the pattern.
                string[] directoryEntries =
                    System.IO.Directory.GetFileSystemEntries(path, pattern);

                foreach (string str in directoryEntries)
                {
                    System.Console.WriteLine(str);
                }
            }
            catch (ArgumentNullException)
            {
                System.Console.WriteLine("Path is a null reference.");
            }
            catch (System.Security.SecurityException)
            {
                System.Console.WriteLine("The caller does not have the " +
                    "required permission.");
            }
            catch (ArgumentException)
            {
                System.Console.WriteLine("Path is an empty string, " +
                    "contains only white spaces, " +
                    "or contains invalid characters.");
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                System.Console.WriteLine("The path encapsulated in the " +
                    "Directory object does not exist.");
            }
        }

        // Print out all logical drives on the system.
        void GetLogicalDrives()
        {
            try
            {
                string[] drives = System.IO.Directory.GetLogicalDrives();

                foreach (string str in drives)
                {
                    System.Console.WriteLine(str);
                }
            }
            catch (System.IO.IOException)
            {
                System.Console.WriteLine("An I/O error occurs.");
            }
            catch (System.Security.SecurityException)
            {
                System.Console.WriteLine("The caller does not have the " +
                    "required permission.");
            }
        }
        void GetParent(string path)
        {
            try
            {
                System.IO.DirectoryInfo directoryInfo =
                    System.IO.Directory.GetParent(path);

                System.Console.WriteLine(directoryInfo.FullName);
            }
            catch (ArgumentNullException)
            {
                System.Console.WriteLine("Path is a null reference.");
            }
            catch (ArgumentException)
            {
                System.Console.WriteLine("Path is an empty string, " +
                    "contains only white spaces, or " +
                    "contains invalid characters.");
            }
        }
        void Move(string sourcePath, string destinationPath)
        {
            try
            {
                System.IO.Directory.Move(sourcePath, destinationPath);
                System.Console.WriteLine("The directory move is complete.");
            }
            catch (ArgumentNullException)
            {
                System.Console.WriteLine("Path is a null reference.");
            }
            catch (System.Security.SecurityException)
            {
                System.Console.WriteLine("The caller does not have the " +
                    "required permission.");
            }
            catch (ArgumentException)
            {
                System.Console.WriteLine("Path is an empty string, " +
                    "contains only white spaces, " +
                    "or contains invalid characters.");	
            }
            catch (System.IO.IOException)
            {
                System.Console.WriteLine("An attempt was made to move a " +
                    "directory to a different " +
                    "volume, or destDirName " +
                    "already exists.");
            }
        }
    }
}
open System
open System.IO
open System.Security

let printFileSystemEntries path =
    try
        // Obtain the file system entries in the directory path.
        let directoryEntries = Directory.GetFileSystemEntries path

        for str in directoryEntries do
            printfn $"{str}"
    with 
    | :? ArgumentNullException ->
        printfn "Path is a null reference."
    | :? SecurityException ->
        printfn $"The caller does not have the required permission."
    | :? ArgumentException ->
        printfn $"Path is an empty string, contains only white spaces, or contains invalid characters."
    | :? DirectoryNotFoundException ->
        printfn $"The path encapsulated in the Directory object does not exist."

let printFileSystemEntriesPattern path pattern =
    try
        // Obtain the file system entries in the directory
        // path that match the pattern.
        let directoryEntries = Directory.GetFileSystemEntries(path, pattern)

        for str in directoryEntries do
            printfn $"{str}"
    with
    | :? ArgumentNullException -> printfn "Path is a null reference."
    | :? SecurityException -> printfn "The caller does not have the required permission."
    | :? ArgumentException -> printfn "Path is an empty string, contains only white spaces, or contains invalid characters."
    | :? DirectoryNotFoundException -> printfn "The path encapsulated in the Directory object does not exist."

// Print out all logical drives on the system.
let getLogicalDrives () =
    try
        let drives = Directory.GetLogicalDrives()

        for str in drives do
            printfn $"{str}"
    with
    | :? IOException -> printfn "An I/O error occurs."
    | :? SecurityException -> printfn "The caller does not have the required permission."

let getParent path =
    try
        let directoryInfo = Directory.GetParent path
        printfn $"{directoryInfo.FullName}"

    with
    | :? ArgumentNullException -> printfn "Path is a null reference."
    | :? ArgumentException -> printfn "Path is an empty string, contains only white spaces, or contains invalid characters."

let move sourcePath destinationPath =
    try
        Directory.Move(sourcePath, destinationPath)
        printfn "The directory move is complete."

    with
    | :? ArgumentNullException -> printfn "Path is a null reference."
    | :? SecurityException -> printfn "The caller does not have the required permission."
    | :? ArgumentException -> printfn "Path is an empty string, contains only white spaces, or contains invalid characters."
    | :? IOException -> printfn "An attempt was made to move a directory to a different volume, or destDirName already exists."

let path = Directory.GetCurrentDirectory()
let filter = "*.exe"

printFileSystemEntries path
printFileSystemEntriesPattern path filter
getLogicalDrives ()
getParent path
move "C:\\proof" "C:\\Temp"
Option Explicit On 
Option Strict On

Namespace GetFileSystemEntries
    Class Class1
        Overloads Shared Sub Main(ByVal args() As String)
            Dim snippets As New Class1()
            Dim path As String = System.IO.Directory.GetCurrentDirectory()
            Dim filter As String = "*.exe"
            snippets.PrintFileSystemEntries(path)
            snippets.PrintFileSystemEntries(path, filter)
            snippets.GetLogicalDrives()
            snippets.GetParent(path)
            snippets.Move("C:\proof", "C:\Temp")
        End Sub

        Sub PrintFileSystemEntries(ByVal path As String)
            Try
                ' Obtain the file system entries in the directory path.
                Dim directoryEntries As String()
                directoryEntries = System.IO.Directory.GetFileSystemEntries(path)
                Dim str As String
                For Each str In directoryEntries
                    System.Console.WriteLine(str)
                Next str
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As System.Security.SecurityException
                System.Console.WriteLine("The caller does not have the " + _
                                        "required permission.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                        "contains only white spaces, " + _
                                        "or contains invalid characters.")
            Catch exp As System.IO.DirectoryNotFoundException
                System.Console.WriteLine("The path encapsulated in the " + _
                                        "Directory object does not exist.")
            End Try
        End Sub
        Sub PrintFileSystemEntries(ByVal path As String, _
                                   ByVal pattern As String)
            Try
                ' Obtain the file system entries in the directory
                ' path that match the pattern.
                Dim directoryEntries As String()
                directoryEntries = _
                   System.IO.Directory.GetFileSystemEntries(path, pattern)

                Dim str As String
                For Each str In directoryEntries
                    System.Console.WriteLine(str)
                Next str
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As System.Security.SecurityException
                System.Console.WriteLine("The caller does not have the " + _
                                        "required permission.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                        "contains only white spaces, " + _
                                        "or contains invalid characters.")
            Catch exp As System.IO.DirectoryNotFoundException
                System.Console.WriteLine("The path encapsulated in the " + _
                                        "Directory object does not exist.")
            End Try
        End Sub

        ' Print out all logical drives on the system.
        Sub GetLogicalDrives()
            Try
                Dim drives As String()
                drives = System.IO.Directory.GetLogicalDrives()

                Dim str As String
                For Each str In drives
                    System.Console.WriteLine(str)
                Next str
            Catch exp As System.IO.IOException
                System.Console.WriteLine("An I/O error occurs.")
            Catch exp As System.Security.SecurityException
                System.Console.WriteLine("The caller does not have the " + _
                                           "required permission.")
            End Try
        End Sub
        Sub GetParent(ByVal path As String)
            Try
                Dim directoryInfo As System.IO.DirectoryInfo
                directoryInfo = System.IO.Directory.GetParent(path)
                System.Console.WriteLine(directoryInfo.FullName)
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                     "contains only white spaces, or " + _
                                     "contains invalid characters.")
            End Try
        End Sub
        Sub Move(ByVal sourcePath As String, ByVal destinationPath As String)
            Try
                System.IO.Directory.Move(sourcePath, destinationPath)
                System.Console.WriteLine("The directory move is complete.")
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As System.Security.SecurityException
                System.Console.WriteLine("The caller does not have the " + _
                                           "required permission.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                        "contains only white spaces, " + _
                                        "or contains invalid characters.")
            Catch exp As System.IO.IOException
                System.Console.WriteLine("An attempt was made to move a " + _
                                        "directory to a different " + _
                                        "volume, or destDirName " + _
                                        "already exists.")
            End Try
        End Sub
    End Class
End Namespace

설명

반환된 파일 및 디렉터리 이름의 순서는 보장되지 않습니다. 특정 정렬 순서가 Sort 필요한 경우 메서드를 사용합니다.

및 메서드는 EnumerateFileSystemEntries 다음과 같이 다릅니다. 를 사용하면 EnumerateFileSystemEntries전체 컬렉션이 반환되기 전에 항목 컬렉션 열거를 시작할 수 있습니다. 를 사용하는 GetFileSystemEntries경우 배열에 액세스하기 전에 전체 항목 배열이 반환될 때까지 기다려야 GetFileSystemEntries 합니다. 따라서 많은 파일 및 디렉터리 EnumerateFileSystemEntries 로 작업할 때 보다 효율적일 수 있습니다.

이 메서드는 검색 패턴으로 지정된 별표(*)와 동일합니다 GetFileSystemEntries .

path 매개 변수는 상대 경로 또는 절대 경로 정보를 지정할 수 있습니다. 상대 경로 정보는 현재 작업 디렉터리를 기준으로 해석됩니다. 현재 작업 디렉터리를 가져오려면 를 참조하세요 GetCurrentDirectory.

매개 변수의 path 대/소문자 구분은 코드가 실행 중인 파일 시스템의 대/소문자 구분에 해당합니다. 예를 들어 NTFS(기본 Windows 파일 시스템)에서는 대/소문자를 구분하지 않으며 Linux 파일 시스템에서는 대/소문자를 구분합니다.

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

추가 정보

적용 대상

GetFileSystemEntries(String, String)

Source:
Directory.cs
Source:
Directory.cs
Source:
Directory.cs

지정된 경로에서 검색 패턴과 일치하는 파일 및 디렉터리 이름 배열을 반환합니다.

public:
 static cli::array <System::String ^> ^ GetFileSystemEntries(System::String ^ path, System::String ^ searchPattern);
public static string[] GetFileSystemEntries (string path, string searchPattern);
static member GetFileSystemEntries : string * string -> string[]
Public Shared Function GetFileSystemEntries (path As String, searchPattern As String) As String()

매개 변수

path
String

검색할 디렉터리에 대한 상대 또는 절대 경로입니다. 이 문자열은 대/소문자를 구분하지 않습니다.

searchPattern
String

path에 있는 파일 및 디렉터리 이름과 일치하는지 비교할 검색 문자열입니다. 이 매개 변수는 유효한 리터럴 경로와 와일드카드(* 및 ?) 문자로 된 조합을 포함하지만 정규식을 지원하지 않습니다.

반환

String[]

지정된 검색 조건과 일치하는 파일 이름 및 디렉터리 이름의 배열이거나 파일 또는 디렉터리가 없으면 빈 배열입니다.

예외

호출자에게 필요한 권한이 없는 경우

2.1보다 오래된 .NET Framework 및 .NET Core 버전: path 길이가 0인 문자열이거나, 공백만 포함하거나, 하나 이상의 잘못된 문자를 포함합니다. GetInvalidPathChars() 메서드를 사용하여 잘못된 문자를 쿼리할 수 있습니다.

또는

searchPattern에 유효한 패턴이 포함되어 있지 않습니다.

path 또는 searchPatternnull인 경우

지정된 경로, 파일 이름 또는 둘 다가 시스템에서 정의한 최대 길이를 초과합니다.

path는 파일 이름입니다.

지정된 경로가 잘못되었습니다(예: 매핑되지 않은 드라이브에 있음).

예제

다음 예제에서는 메서드를 GetFileSystemEntries 사용하여 특정 위치에서 사용자가 지정한 필터와 일치하는 모든 파일의 이름으로 문자열 배열을 채우고 배열의 각 문자열을 콘솔에 출력합니다. 이 예제는 이 메서드에 공통된 모든 오류를 catch하도록 구성됩니다.

using namespace System;
class Class1
{
public:
   void PrintFileSystemEntries( String^ path )
   {
      try
      {
         
         // Obtain the file system entries in the directory path.
         array<String^>^directoryEntries = System::IO::Directory::GetFileSystemEntries( path );
         for ( int i = 0; i < directoryEntries->Length; i++ )
         {
            System::Console::WriteLine( directoryEntries[ i ] );

         }
      }
      catch ( ArgumentNullException^ ) 
      {
         System::Console::WriteLine(  "Path is a null reference." );
      }
      catch ( System::Security::SecurityException^ ) 
      {
         System::Console::WriteLine(  "The caller does not have the \HelloServer'                  required permission." );
      }
      catch ( ArgumentException^ ) 
      {
         System::Console::WriteLine(  "Path is an empty String, \HelloServer'                  contains only white spaces, \HelloServer'                  or contains invalid characters." );
      }
      catch ( System::IO::DirectoryNotFoundException^ ) 
      {
         System::Console::WriteLine(  "The path encapsulated in the \HelloServer'                  Directory object does not exist." );
      }

   }

   void PrintFileSystemEntries( String^ path, String^ pattern )
   {
      try
      {
         
         // Obtain the file system entries in the directory
         // path that match the pattern.
         array<String^>^directoryEntries = System::IO::Directory::GetFileSystemEntries( path, pattern );
         for ( int i = 0; i < directoryEntries->Length; i++ )
         {
            System::Console::WriteLine( directoryEntries[ i ] );

         }
      }
      catch ( ArgumentNullException^ ) 
      {
         System::Console::WriteLine(  "Path is a null reference." );
      }
      catch ( System::Security::SecurityException^ ) 
      {
         System::Console::WriteLine(  "The caller does not have the \HelloServer'                  required permission." );
      }
      catch ( ArgumentException^ ) 
      {
         System::Console::WriteLine(  "Path is an empty String, \HelloServer'                  contains only white spaces, \HelloServer'                  or contains invalid characters." );
      }
      catch ( System::IO::DirectoryNotFoundException^ ) 
      {
         System::Console::WriteLine(  "The path encapsulated in the \HelloServer'                  Directory object does not exist." );
      }

   }


   // Print out all logical drives on the system.
   void GetLogicalDrives()
   {
      try
      {
         array<String^>^drives = System::IO::Directory::GetLogicalDrives();
         for ( int i = 0; i < drives->Length; i++ )
         {
            System::Console::WriteLine( drives[ i ] );

         }
      }
      catch ( System::IO::IOException^ ) 
      {
         System::Console::WriteLine(  "An I/O error occurs." );
      }
      catch ( System::Security::SecurityException^ ) 
      {
         System::Console::WriteLine(  "The caller does not have the \HelloServer'                  required permission." );
      }

   }

   void GetParent( String^ path )
   {
      try
      {
         System::IO::DirectoryInfo^ directoryInfo = System::IO::Directory::GetParent( path );
         System::Console::WriteLine( directoryInfo->FullName );
      }
      catch ( ArgumentNullException^ ) 
      {
         System::Console::WriteLine(  "Path is a null reference." );
      }
      catch ( ArgumentException^ ) 
      {
         System::Console::WriteLine(  "Path is an empty String, \HelloServer'                  contains only white spaces, or \HelloServer'                  contains invalid characters." );
      }

   }

   void Move( String^ sourcePath, String^ destinationPath )
   {
      try
      {
         System::IO::Directory::Move( sourcePath, destinationPath );
         System::Console::WriteLine(  "The directory move is complete." );
      }
      catch ( ArgumentNullException^ ) 
      {
         System::Console::WriteLine(  "Path is a null reference." );
      }
      catch ( System::Security::SecurityException^ ) 
      {
         System::Console::WriteLine(  "The caller does not have the \HelloServer'                  required permission." );
      }
      catch ( ArgumentException^ ) 
      {
         System::Console::WriteLine(  "Path is an empty String, \HelloServer'                  contains only white spaces, \HelloServer'                  or contains invalid characters." );
      }
      catch ( System::IO::IOException^ ) 
      {
         System::Console::WriteLine(  "An attempt was made to move a \HelloServer'                  directory to a different \HelloServer'                  volume, or destDirName \HelloServer'                  already exists." );
      }

   }

};

int main()
{
   Class1 * snippets = new Class1;
   String^ path = System::IO::Directory::GetCurrentDirectory();
   String^ filter =  "*.exe";
   snippets->PrintFileSystemEntries( path );
   snippets->PrintFileSystemEntries( path, filter );
   snippets->GetLogicalDrives();
   snippets->GetParent( path );
   snippets->Move(  "C:\\proof",  "C:\\Temp" );
   return 0;
}
using System;

namespace GetFileSystemEntries
{
    class Class1
    {
        static void Main(string[] args)
        {
            Class1 snippets = new Class1();

            string path = System.IO.Directory.GetCurrentDirectory();
            string filter = "*.exe";

            snippets.PrintFileSystemEntries(path);
            snippets.PrintFileSystemEntries(path, filter);		
            snippets.GetLogicalDrives();
            snippets.GetParent(path);
            snippets.Move("C:\\proof", "C:\\Temp");
        }

        void PrintFileSystemEntries(string path)
        {
            
            try
            {
                // Obtain the file system entries in the directory path.
                string[] directoryEntries =
                    System.IO.Directory.GetFileSystemEntries(path);

                foreach (string str in directoryEntries)
                {
                    System.Console.WriteLine(str);
                }
            }
            catch (ArgumentNullException)
            {
                System.Console.WriteLine("Path is a null reference.");
            }
            catch (System.Security.SecurityException)
            {
                System.Console.WriteLine("The caller does not have the " +
                    "required permission.");
            }
            catch (ArgumentException)
            {
                System.Console.WriteLine("Path is an empty string, " +
                    "contains only white spaces, " +
                    "or contains invalid characters.");
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                System.Console.WriteLine("The path encapsulated in the " +
                    "Directory object does not exist.");
            }
        }
        void PrintFileSystemEntries(string path, string pattern)
        {
            try
            {
                // Obtain the file system entries in the directory
                // path that match the pattern.
                string[] directoryEntries =
                    System.IO.Directory.GetFileSystemEntries(path, pattern);

                foreach (string str in directoryEntries)
                {
                    System.Console.WriteLine(str);
                }
            }
            catch (ArgumentNullException)
            {
                System.Console.WriteLine("Path is a null reference.");
            }
            catch (System.Security.SecurityException)
            {
                System.Console.WriteLine("The caller does not have the " +
                    "required permission.");
            }
            catch (ArgumentException)
            {
                System.Console.WriteLine("Path is an empty string, " +
                    "contains only white spaces, " +
                    "or contains invalid characters.");
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                System.Console.WriteLine("The path encapsulated in the " +
                    "Directory object does not exist.");
            }
        }

        // Print out all logical drives on the system.
        void GetLogicalDrives()
        {
            try
            {
                string[] drives = System.IO.Directory.GetLogicalDrives();

                foreach (string str in drives)
                {
                    System.Console.WriteLine(str);
                }
            }
            catch (System.IO.IOException)
            {
                System.Console.WriteLine("An I/O error occurs.");
            }
            catch (System.Security.SecurityException)
            {
                System.Console.WriteLine("The caller does not have the " +
                    "required permission.");
            }
        }
        void GetParent(string path)
        {
            try
            {
                System.IO.DirectoryInfo directoryInfo =
                    System.IO.Directory.GetParent(path);

                System.Console.WriteLine(directoryInfo.FullName);
            }
            catch (ArgumentNullException)
            {
                System.Console.WriteLine("Path is a null reference.");
            }
            catch (ArgumentException)
            {
                System.Console.WriteLine("Path is an empty string, " +
                    "contains only white spaces, or " +
                    "contains invalid characters.");
            }
        }
        void Move(string sourcePath, string destinationPath)
        {
            try
            {
                System.IO.Directory.Move(sourcePath, destinationPath);
                System.Console.WriteLine("The directory move is complete.");
            }
            catch (ArgumentNullException)
            {
                System.Console.WriteLine("Path is a null reference.");
            }
            catch (System.Security.SecurityException)
            {
                System.Console.WriteLine("The caller does not have the " +
                    "required permission.");
            }
            catch (ArgumentException)
            {
                System.Console.WriteLine("Path is an empty string, " +
                    "contains only white spaces, " +
                    "or contains invalid characters.");	
            }
            catch (System.IO.IOException)
            {
                System.Console.WriteLine("An attempt was made to move a " +
                    "directory to a different " +
                    "volume, or destDirName " +
                    "already exists.");
            }
        }
    }
}
open System
open System.IO
open System.Security

let printFileSystemEntries path =
    try
        // Obtain the file system entries in the directory path.
        let directoryEntries = Directory.GetFileSystemEntries path

        for str in directoryEntries do
            printfn $"{str}"
    with 
    | :? ArgumentNullException ->
        printfn "Path is a null reference."
    | :? SecurityException ->
        printfn $"The caller does not have the required permission."
    | :? ArgumentException ->
        printfn $"Path is an empty string, contains only white spaces, or contains invalid characters."
    | :? DirectoryNotFoundException ->
        printfn $"The path encapsulated in the Directory object does not exist."

let printFileSystemEntriesPattern path pattern =
    try
        // Obtain the file system entries in the directory
        // path that match the pattern.
        let directoryEntries = Directory.GetFileSystemEntries(path, pattern)

        for str in directoryEntries do
            printfn $"{str}"
    with
    | :? ArgumentNullException -> printfn "Path is a null reference."
    | :? SecurityException -> printfn "The caller does not have the required permission."
    | :? ArgumentException -> printfn "Path is an empty string, contains only white spaces, or contains invalid characters."
    | :? DirectoryNotFoundException -> printfn "The path encapsulated in the Directory object does not exist."

// Print out all logical drives on the system.
let getLogicalDrives () =
    try
        let drives = Directory.GetLogicalDrives()

        for str in drives do
            printfn $"{str}"
    with
    | :? IOException -> printfn "An I/O error occurs."
    | :? SecurityException -> printfn "The caller does not have the required permission."

let getParent path =
    try
        let directoryInfo = Directory.GetParent path
        printfn $"{directoryInfo.FullName}"

    with
    | :? ArgumentNullException -> printfn "Path is a null reference."
    | :? ArgumentException -> printfn "Path is an empty string, contains only white spaces, or contains invalid characters."

let move sourcePath destinationPath =
    try
        Directory.Move(sourcePath, destinationPath)
        printfn "The directory move is complete."

    with
    | :? ArgumentNullException -> printfn "Path is a null reference."
    | :? SecurityException -> printfn "The caller does not have the required permission."
    | :? ArgumentException -> printfn "Path is an empty string, contains only white spaces, or contains invalid characters."
    | :? IOException -> printfn "An attempt was made to move a directory to a different volume, or destDirName already exists."

let path = Directory.GetCurrentDirectory()
let filter = "*.exe"

printFileSystemEntries path
printFileSystemEntriesPattern path filter
getLogicalDrives ()
getParent path
move "C:\\proof" "C:\\Temp"
Option Explicit On 
Option Strict On

Namespace GetFileSystemEntries
    Class Class1
        Overloads Shared Sub Main(ByVal args() As String)
            Dim snippets As New Class1()
            Dim path As String = System.IO.Directory.GetCurrentDirectory()
            Dim filter As String = "*.exe"
            snippets.PrintFileSystemEntries(path)
            snippets.PrintFileSystemEntries(path, filter)
            snippets.GetLogicalDrives()
            snippets.GetParent(path)
            snippets.Move("C:\proof", "C:\Temp")
        End Sub

        Sub PrintFileSystemEntries(ByVal path As String)
            Try
                ' Obtain the file system entries in the directory path.
                Dim directoryEntries As String()
                directoryEntries = System.IO.Directory.GetFileSystemEntries(path)
                Dim str As String
                For Each str In directoryEntries
                    System.Console.WriteLine(str)
                Next str
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As System.Security.SecurityException
                System.Console.WriteLine("The caller does not have the " + _
                                        "required permission.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                        "contains only white spaces, " + _
                                        "or contains invalid characters.")
            Catch exp As System.IO.DirectoryNotFoundException
                System.Console.WriteLine("The path encapsulated in the " + _
                                        "Directory object does not exist.")
            End Try
        End Sub
        Sub PrintFileSystemEntries(ByVal path As String, _
                                   ByVal pattern As String)
            Try
                ' Obtain the file system entries in the directory
                ' path that match the pattern.
                Dim directoryEntries As String()
                directoryEntries = _
                   System.IO.Directory.GetFileSystemEntries(path, pattern)

                Dim str As String
                For Each str In directoryEntries
                    System.Console.WriteLine(str)
                Next str
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As System.Security.SecurityException
                System.Console.WriteLine("The caller does not have the " + _
                                        "required permission.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                        "contains only white spaces, " + _
                                        "or contains invalid characters.")
            Catch exp As System.IO.DirectoryNotFoundException
                System.Console.WriteLine("The path encapsulated in the " + _
                                        "Directory object does not exist.")
            End Try
        End Sub

        ' Print out all logical drives on the system.
        Sub GetLogicalDrives()
            Try
                Dim drives As String()
                drives = System.IO.Directory.GetLogicalDrives()

                Dim str As String
                For Each str In drives
                    System.Console.WriteLine(str)
                Next str
            Catch exp As System.IO.IOException
                System.Console.WriteLine("An I/O error occurs.")
            Catch exp As System.Security.SecurityException
                System.Console.WriteLine("The caller does not have the " + _
                                           "required permission.")
            End Try
        End Sub
        Sub GetParent(ByVal path As String)
            Try
                Dim directoryInfo As System.IO.DirectoryInfo
                directoryInfo = System.IO.Directory.GetParent(path)
                System.Console.WriteLine(directoryInfo.FullName)
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                     "contains only white spaces, or " + _
                                     "contains invalid characters.")
            End Try
        End Sub
        Sub Move(ByVal sourcePath As String, ByVal destinationPath As String)
            Try
                System.IO.Directory.Move(sourcePath, destinationPath)
                System.Console.WriteLine("The directory move is complete.")
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As System.Security.SecurityException
                System.Console.WriteLine("The caller does not have the " + _
                                           "required permission.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                        "contains only white spaces, " + _
                                        "or contains invalid characters.")
            Catch exp As System.IO.IOException
                System.Console.WriteLine("An attempt was made to move a " + _
                                        "directory to a different " + _
                                        "volume, or destDirName " + _
                                        "already exists.")
            End Try
        End Sub
    End Class
End Namespace

설명

반환된 파일 및 디렉터리 이름의 순서는 보장되지 않습니다. 특정 정렬 순서가 Sort 필요한 경우 메서드를 사용합니다.

searchPattern 는 리터럴 문자와 와일드카드 문자의 조합일 수 있지만 정규식을 지원하지는 않습니다. 에서 허용되는 와일드카드 지정자는 다음과 같습니다 searchPattern.

와일드카드 지정자 일치하는 항목
*(별표) 해당 위치에 0개 이상의 문자가 있습니다.
? (물음표) 해당 위치에 정확히 한 문자가 있습니다.

와일드카드 이외의 문자는 리터럴 문자입니다. 예를 들어 searchPattern 문자열 "*t"는 문자 "t"로 끝나는 의 모든 이름을 path 검색합니다. 문자열 "s*"는 searchPattern 문자 "s"로 path 시작하는 의 모든 이름을 검색합니다.

searchPattern 는 두 개의 마침표("..")로 끝나거나 두 개의 마침표("..") 뒤에 DirectorySeparatorChar 또는 AltDirectorySeparatorChar를 포함할 수 없으며 잘못된 문자를 포함할 수도 없습니다. GetInvalidPathChars 메서드를 사용하여 잘못된 문자를 쿼리할 수 있습니다.

참고

"*.txt"과 같은 별표 와일드카드 문자를 searchPattern 사용하는 경우 지정된 확장의 문자 수는 다음과 같이 검색에 영향을 줍니다.

  • 지정된 확장의 길이가 정확히 3자이면 메서드는 지정된 확장으로 시작하는 확장명을 가진 파일을 반환합니다. 예를 들어 "*.xls"은 "book.xls" 및 "book.xlsx"를 모두 반환합니다.
  • 다른 모든 경우에서 메서드는 지정된 확장과 정확히 일치하는 파일을 반환합니다. 예를 들어 "*.ai"는 "file.aif"가 아닌 "file.ai"을 반환합니다.

물음표 와일드카드 문자를 사용하는 경우 이 메서드는 지정된 파일 확장명과 일치하는 파일만 반환합니다. 예를 들어 디렉터리에서 "file1.txt" 및 "file1.txtother"라는 두 개의 파일이 지정된 경우 "file?.txt"의 검색 패턴은 첫 번째 파일만 반환하는 반면 "file*.txt"의 검색 패턴은 두 파일을 모두 반환합니다.

path 매개 변수는 상대 경로 또는 절대 경로 정보를 지정할 수 있습니다. 상대 경로 정보는 현재 작업 디렉터리를 기준으로 해석됩니다. 현재 작업 디렉터리를 가져오려면 를 참조하세요 GetCurrentDirectory.

매개 변수의 path 대/소문자 구분은 코드가 실행 중인 파일 시스템의 대/소문자 구분에 해당합니다. 예를 들어 NTFS(기본 Windows 파일 시스템)에서는 대/소문자를 구분하지 않으며 Linux 파일 시스템에서는 대/소문자를 구분합니다.

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

추가 정보

적용 대상

GetFileSystemEntries(String, String, EnumerationOptions)

Source:
Directory.cs
Source:
Directory.cs
Source:
Directory.cs

지정된 경로에서 검색 패턴 및 열거형 옵션과 일치하는 파일 이름 및 디렉터리 이름의 배열을 반환합니다.

public:
 static cli::array <System::String ^> ^ GetFileSystemEntries(System::String ^ path, System::String ^ searchPattern, System::IO::EnumerationOptions ^ enumerationOptions);
public static string[] GetFileSystemEntries (string path, string searchPattern, System.IO.EnumerationOptions enumerationOptions);
static member GetFileSystemEntries : string * string * System.IO.EnumerationOptions -> string[]
Public Shared Function GetFileSystemEntries (path As String, searchPattern As String, enumerationOptions As EnumerationOptions) As String()

매개 변수

path
String

검색할 디렉터리에 대한 상대 또는 절대 경로입니다. 이 문자열은 대/소문자를 구분하지 않습니다.

searchPattern
String

path에 있는 하위 디렉터리 이름과 일치하는지 비교할 검색 문자열입니다. 이 매개 변수는 유효한 리터럴 및 와일드카드 문자로 된 조합을 포함하지만 정규식을 지원하지 않습니다.

enumerationOptions
EnumerationOptions

사용할 검색 및 열거형 구성을 설명하는 개체입니다.

반환

String[]

지정된 검색 패턴 및 열거형 옵션과 일치하는 파일 이름 및 디렉터리 이름의 배열이거나 파일 또는 디렉터리가 없으면 빈 배열입니다.

예외

호출자에게 필요한 권한이 없는 경우

2.1보다 오래된 .NET Framework 및 .NET Core 버전: path 길이가 0인 문자열이거나, 공백만 포함하거나, 하나 이상의 잘못된 문자를 포함합니다. GetInvalidPathChars() 메서드를 사용하여 잘못된 문자를 쿼리할 수 있습니다.

또는

searchPattern에 유효한 패턴이 포함되어 있지 않습니다.

path 또는 searchPatternnull인 경우

지정된 경로, 파일 이름 또는 둘 다가 시스템에서 정의한 최대 길이를 초과합니다.

path는 파일 이름입니다.

지정된 경로가 잘못되었습니다(예: 매핑되지 않은 드라이브에 있음).

설명

반환된 파일 및 디렉터리 이름의 순서는 보장되지 않습니다. 특정 정렬 순서가 Sort 필요한 경우 메서드를 사용합니다.

searchPattern 는 리터럴 문자와 와일드카드 문자의 조합일 수 있지만 정규식을 지원하지는 않습니다. 에서 허용되는 와일드카드 지정자는 다음과 같습니다 searchPattern.

와일드카드 지정자 일치하는 항목
*(별표) 해당 위치에 0개 이상의 문자가 있습니다.
? (물음표) 해당 위치에 정확히 한 문자가 있습니다.

와일드카드 이외의 문자는 리터럴 문자입니다. 예를 들어 searchPattern 문자열 "*t"는 문자 "t"로 끝나는 의 모든 이름을 path 검색합니다. 문자열 "s*"는 searchPattern 문자 "s"로 path 시작하는 의 모든 이름을 검색합니다.

searchPattern 는 두 개의 마침표("..")로 끝나거나 두 개의 마침표("..") 뒤에 DirectorySeparatorChar 또는 AltDirectorySeparatorChar를 포함할 수 없으며 잘못된 문자를 포함할 수도 없습니다. GetInvalidPathChars 메서드를 사용하여 잘못된 문자를 쿼리할 수 있습니다.

참고

"*.txt"과 같은 별표 와일드카드 문자를 searchPattern 사용하는 경우 지정된 확장의 문자 수는 다음과 같이 검색에 영향을 줍니다.

  • 지정된 확장의 길이가 정확히 3자이면 메서드는 지정된 확장으로 시작하는 확장명을 가진 파일을 반환합니다. 예를 들어 "*.xls"은 "book.xls" 및 "book.xlsx"를 모두 반환합니다.
  • 다른 모든 경우에서 메서드는 지정된 확장과 정확히 일치하는 파일을 반환합니다. 예를 들어 "*.ai"는 "file.aif"가 아닌 "file.ai"을 반환합니다.

물음표 와일드카드 문자를 사용하는 경우 이 메서드는 지정된 파일 확장명과 일치하는 파일만 반환합니다. 예를 들어 디렉터리에서 "file1.txt" 및 "file1.txtother"라는 두 개의 파일이 지정된 경우 "file?.txt"의 검색 패턴은 첫 번째 파일만 반환하는 반면 "file*.txt"의 검색 패턴은 두 파일을 모두 반환합니다.

path 매개 변수는 상대 경로 또는 절대 경로 정보를 지정할 수 있습니다. 상대 경로 정보는 현재 작업 디렉터리를 기준으로 해석됩니다. 현재 작업 디렉터리를 가져오려면 를 참조하세요 GetCurrentDirectory.

매개 변수의 path 대/소문자 구분은 코드가 실행 중인 파일 시스템의 대/소문자 구분에 해당합니다. 예를 들어 NTFS(기본 Windows 파일 시스템)에서는 대/소문자를 구분하지 않으며 Linux 파일 시스템에서는 대/소문자를 구분합니다.

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

적용 대상

GetFileSystemEntries(String, String, SearchOption)

Source:
Directory.cs
Source:
Directory.cs
Source:
Directory.cs

지정된 경로에서 검색 패턴과 일치하는 모든 파일 이름 및 디렉터리 이름의 배열을 가져오고 선택적으로 하위 디렉터리를 반환합니다.

public:
 static cli::array <System::String ^> ^ GetFileSystemEntries(System::String ^ path, System::String ^ searchPattern, System::IO::SearchOption searchOption);
public static string[] GetFileSystemEntries (string path, string searchPattern, System.IO.SearchOption searchOption);
static member GetFileSystemEntries : string * string * System.IO.SearchOption -> string[]
Public Shared Function GetFileSystemEntries (path As String, searchPattern As String, searchOption As SearchOption) As String()

매개 변수

path
String

검색할 디렉터리에 대한 상대 또는 절대 경로입니다. 이 문자열은 대/소문자를 구분하지 않습니다.

searchPattern
String

path에 있는 파일 및 디렉터리 이름과 일치하는지 비교할 검색 문자열입니다. 이 매개 변수는 유효한 리터럴 경로와 와일드카드(* 및 ?) 문자로 된 조합을 포함하지만 정규식을 지원하지 않습니다.

searchOption
SearchOption

검색 작업에 현재 디렉터리만 포함할지 아니면 모든 하위 디렉터리를 포함할지를 지정하는 열거형 값 중 하나입니다. 기본값은 TopDirectoryOnly입니다.

반환

String[]

지정된 검색 조건과 일치하는 파일, 파일 이름 및 디렉터리 이름의 배열이거나 파일 또는 디렉터리가 없으면 빈 배열입니다.

예외

2.1보다 오래된 .NET Framework 및 .NET Core 버전: path 길이가 0인 문자열이거나, 공백만 포함하거나, 잘못된 문자를 포함합니다. GetInvalidPathChars() 메서드를 사용하여 잘못된 문자를 쿼리할 수 있습니다.

또는

searchPattern에 유효한 패턴이 포함되어 있지 않습니다.

path이(가) null인 경우

또는

searchPatternnull입니다.

searchOption는 유효한 SearchOption 값이 아닙니다.

path가 잘못되었습니다(예: 매핑되지 않은 드라이브 참조).

path는 파일 이름입니다.

지정된 경로, 파일 이름 또는 이 둘의 조합이 시스템에서 정의한 최대 길이를 초과합니다.

호출자에게 필요한 권한이 없는 경우

호출자에게 필요한 권한이 없는 경우

설명

반환된 파일 및 디렉터리 이름의 순서는 보장되지 않습니다. 특정 정렬 순서가 Sort 필요한 경우 메서드를 사용합니다.

searchPattern 는 리터럴 문자와 와일드카드 문자의 조합일 수 있지만 정규식을 지원하지는 않습니다. 에서 허용되는 와일드카드 지정자는 다음과 같습니다 searchPattern.

와일드카드 지정자 일치하는 항목
*(별표) 해당 위치에 0개 이상의 문자가 있습니다.
? (물음표) 해당 위치에 정확히 한 문자가 있습니다.

와일드카드 이외의 문자는 리터럴 문자입니다. 예를 들어 searchPattern 문자열 "*t"는 문자 "t"로 끝나는 의 모든 이름을 path 검색합니다. 문자열 "s*"는 searchPattern 문자 "s"로 path 시작하는 의 모든 이름을 검색합니다.

searchPattern 는 두 개의 마침표("..")로 끝나거나 두 개의 마침표("..") 뒤에 DirectorySeparatorChar 또는 AltDirectorySeparatorChar를 포함할 수 없으며 잘못된 문자를 포함할 수도 없습니다. GetInvalidPathChars 메서드를 사용하여 잘못된 문자를 쿼리할 수 있습니다.

참고

"*.txt"과 같은 별표 와일드카드 문자를 searchPattern 사용하는 경우 지정된 확장의 문자 수는 다음과 같이 검색에 영향을 줍니다.

  • 지정된 확장의 길이가 정확히 3자이면 메서드는 지정된 확장으로 시작하는 확장명을 가진 파일을 반환합니다. 예를 들어 "*.xls"은 "book.xls" 및 "book.xlsx"를 모두 반환합니다.
  • 다른 모든 경우에서 메서드는 지정된 확장과 정확히 일치하는 파일을 반환합니다. 예를 들어 "*.ai"는 "file.aif"가 아닌 "file.ai"을 반환합니다.

물음표 와일드카드 문자를 사용하는 경우 이 메서드는 지정된 파일 확장명과 일치하는 파일만 반환합니다. 예를 들어 디렉터리에서 "file1.txt" 및 "file1.txtother"라는 두 개의 파일이 지정된 경우 "file?.txt"의 검색 패턴은 첫 번째 파일만 반환하는 반면 "file*.txt"의 검색 패턴은 두 파일을 모두 반환합니다.

및 메서드는 EnumerateFileSystemEntries 다음과 같이 다릅니다. 를 사용하면 EnumerateFileSystemEntries전체 컬렉션이 반환되기 전에 항목 컬렉션 열거를 시작할 수 있습니다. 를 사용하는 GetFileSystemEntries경우 배열에 액세스하기 전에 전체 항목 배열이 반환될 때까지 기다려야 GetFileSystemEntries 합니다. 따라서 많은 파일 및 디렉터리 EnumerateFileSystemEntries 로 작업할 때 보다 효율적일 수 있습니다.

매개 변수를 path 사용하여 상대 경로 정보를 지정할 수 있습니다. 상대 경로 정보는 메서드를 사용하여 GetCurrentDirectory 확인할 수 있는 현재 작업 디렉터리를 기준으로 해석됩니다.

추가 정보

적용 대상