IsolatedStorageFile.GetFileNames 메서드

정의

격리된 저장소의 루트에 있는 파일 이름을 열거합니다.

오버로드

GetFileNames()

격리된 저장소의 루트에 있는 파일 이름을 열거합니다.

GetFileNames(String)

검색 패턴과 일치하는 파일 이름을 가져옵니다.

GetFileNames()

Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs

격리된 저장소의 루트에 있는 파일 이름을 열거합니다.

public:
 cli::array <System::String ^> ^ GetFileNames();
public string[] GetFileNames ();
[System.Runtime.InteropServices.ComVisible(false)]
public string[] GetFileNames ();
member this.GetFileNames : unit -> string[]
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.GetFileNames : unit -> string[]
Public Function GetFileNames () As String()

반환

String[]

격리된 저장소의 루트에 있는 파일의 상대 경로가 들어 있는 배열입니다. 길이가 0인 배열은 루트에 파일이 없음을 나타냅니다.

특성

예외

격리된 저장소가 제거된 경우

격리된 저장소가 삭제된 경우

격리된 저장소 루트의 파일 경로를 확인할 수 없습니다.

설명

이 메서드는 검색 패턴에 IsolatedStorageFile.GetFileNames(String) 대해 지정된 "*"이 있는 메서드를 사용하는 것과 같습니다.

추가 정보

적용 대상

GetFileNames(String)

Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs

검색 패턴과 일치하는 파일 이름을 가져옵니다.

public:
 cli::array <System::String ^> ^ GetFileNames(System::String ^ searchPattern);
public string[] GetFileNames (string searchPattern);
member this.GetFileNames : string -> string[]
Public Function GetFileNames (searchPattern As String) As String()

매개 변수

searchPattern
String

.검색 패턴입니다. 단일 문자("?") 및 다중 문자("*") 와일드카드를 모두 사용할 수 있습니다.

반환

String[]

격리된 스토리지 범위 내의 파일 중 searchPattern과 일치하는 파일의 상대 경로 배열입니다. 길이가 0인 배열은 일치하는 파일이 없음을 나타냅니다.

예외

searchPattern이(가) null인 경우

격리된 저장소가 삭제된 경우

격리된 저장소가 제거된 경우

searchPattern에서 지정한 파일 경로가 없는 경우

예제

다음 코드 예제는 GetFileNames 메서드. 이 예제의 전체 컨텍스트는 개요를 참조하세요 IsolatedStorageFile .

array<String^>^dirNames = isoFile->GetDirectoryNames( "*" );
array<String^>^fileNames = isoFile->GetFileNames( "*" );

// List directories currently in this Isolated Storage.
if ( dirNames->Length > 0 )
{
   for ( int i = 0; i < dirNames->Length; ++i )
   {
      Console::WriteLine( "Directory Name: {0}", dirNames[ i ] );

   }
}


// List the files currently in this Isolated Storage.
// The list represents all users who have personal preferences stored for this application.
if ( fileNames->Length > 0 )
{
   for ( int i = 0; i < fileNames->Length; ++i )
   {
      Console::WriteLine( "File Name: {0}", fileNames[ i ] );

   }
}
    String[] dirNames = isoFile.GetDirectoryNames("*");
    String[] fileNames = isoFile.GetFileNames("Archive\\*");

    // Delete all the files currently in the Archive directory.

    if (fileNames.Length > 0)
    {
        for (int i = 0; i < fileNames.Length; ++i)
        {
            // Delete the files.
            isoFile.DeleteFile("Archive\\" + fileNames[i]);
        }
        // Confirm that no files remain.
        fileNames = isoFile.GetFileNames("Archive\\*");
    }

    if (dirNames.Length > 0)
    {
        for (int i = 0; i < dirNames.Length; ++i)
        {
            // Delete the Archive directory.
        }
    }
    dirNames = isoFile.GetDirectoryNames("*");
    isoFile.Remove();
}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
}
Dim dirNames As String() = isoFile.GetDirectoryNames("*")
Dim fileNames As String() = isoFile.GetFileNames("*")
Dim name As String

' List directories currently in this Isolated Storage.
If dirNames.Length > 0 Then

    For Each name In dirNames
        Console.WriteLine("Directory Name: " & name)
    Next name
End If

' List the files currently in this Isolated Storage.
' The list represents all users who have personal preferences stored for this application.
If fileNames.Length > 0 Then

    For Each name In fileNames
        Console.WriteLine("File Name: " & name)
    Next name
End If

설명

searchPattern "Project\Data *.txt"는 격리된 스토리지 범위의 프로젝트 디렉터리에서 Data로 시작하는 모든 ".txt" 파일을 제공합니다. 검색 패턴 문자열에 대한 전체 설명은 을 참조하세요 System.IO.Directory.

디렉터리 이름을 찾는 방법에 대한 자세한 내용은 메서드를 GetDirectoryNames 참조하세요.

방법: 격리된 스토리지의 기존 파일 및 디렉터리 찾기 예제는 GetFileNames 메서드의 사용을 보여줍니다.

추가 정보

적용 대상