StorageFolder.CreateFileQuery 메서드

정의

오버로드

CreateFileQuery()

현재 폴더의 파일이 포함된 쿼리 결과 개체를 가져옵니다.

CreateFileQuery(CommonFileQuery)

현재 폴더의 파일이 포함된 쿼리 결과 개체를 가져옵니다. 또한 쿼리 인수의 값이 CommonFileQuery.DefaultQuery 이외의 값인 경우 현재 폴더의 하위 폴더에서 파일을 가져옵니다. 파일은 지정된 CommonFileQuery에 따라 정렬됩니다.

CreateFileQuery()

현재 폴더의 파일이 포함된 쿼리 결과 개체를 가져옵니다.

public:
 virtual StorageFileQueryResult ^ CreateFileQuery() = CreateFileQuery;
/// [Windows.Foundation.Metadata.Overload("CreateFileQueryOverloadDefault")]
StorageFileQueryResult CreateFileQuery();
[Windows.Foundation.Metadata.Overload("CreateFileQueryOverloadDefault")]
public StorageFileQueryResult CreateFileQuery();
function createFileQuery()
Public Function CreateFileQuery () As StorageFileQueryResult

반환

쿼리 결과 개체입니다. 쿼리 결과의 GetFilesAsync 메서드를 호출하여 파일의 플랫 목록을 가져옵니다. 이 메서드는 IReadOnlyList<StorageFile 형식의 목록을 반환합니다>. 각 파일은 StorageFile 형식의 항목으로 표시됩니다.

구현

특성

예제

다음 예제에서는 CreateFileQuery() 메서드를 호출하여 현재 폴더의 파일이 포함된 쿼리 결과 개체를 가져옵니다.

using Windows.Storage;
using Windows.Storage.Search;
using System.Threading.Tasks;
using System.Diagnostics; // For writing results to Output window.

// Get the app's installation folder.
StorageFolder appFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;

// Get the files in the current folder.
StorageFileQueryResult results = appFolder.CreateFileQuery();

// Iterate over the results and print the list of files
// to the Visual Studio Output window.
IReadOnlyList<StorageFile> filesInFolder = await results.GetFilesAsync();
foreach (StorageFile item in filesInFolder)
{
    Debug.WriteLine(item.Name);
}
IAsyncAction MainPage::ExampleCoroutineAsync()
{
    // Get the app's installation folder.
    Windows::Storage::StorageFolder appFolder{ Windows::ApplicationModel::Package::Current().InstalledLocation() };
    // Get the files in the current folder.
    Windows::Storage::Search::StorageFileQueryResult results{ appFolder.CreateFileQuery() };

    Windows::Foundation::Collections::IVectorView<Windows::Storage::StorageFile> filesInFolder{
        co_await results.GetFilesAsync() };

    // Iterate over the results, and print the list of files to the Visual Studio output window.
    for (StorageFile const& fileInFolder : filesInFolder)
    {
        std::wstring output{ fileInFolder.Name() };
        ::OutputDebugString(output.c_str());
    }
}
//Get the app's installation folder
StorageFolder^ appFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;
//Get the files in the current folder
StorageFileQueryResult^ results = appFolder->CreateFileQuery();

create_task(results->GetFilesAsync()).then([=](IVectorView<StorageFile^>^ filesInFolder) {
 //Iterate over the results and print the list of files
 // to the visual studio output window
 for (auto it = filesInFolder->First(); it->HasCurrent; it->MoveNext())
 {
  StorageFile^ file = it->Current;
  String^ output = file->Name + "\n";
  OutputDebugString(output->Begin());
 }
});

설명

이 쿼리는 현재 폴더의 파일만 반환하는 단순 쿼리입니다. 단순 쿼리 및 심층 쿼리를 식별하는 메서드 목록은 GetFilesAsync 항목의 설명을 참조하세요.

GetFilesAsync 메서드 중 하나를 호출하여 현재 폴더의 파일 목록을 비동기적으로 가져올 수도 있습니다.

추가 쿼리 옵션을 지정하려면 CreateFileQueryWithOptions 메서드를 호출합니다 .

파일 또는 폴더인 항목을 얻으려면 CreateItemQuery 메서드를 호출합니다.

추가 정보

적용 대상

CreateFileQuery(CommonFileQuery)

현재 폴더의 파일이 포함된 쿼리 결과 개체를 가져옵니다. 또한 쿼리 인수의 값이 CommonFileQuery.DefaultQuery 이외의 값인 경우 현재 폴더의 하위 폴더에서 파일을 가져옵니다. 파일은 지정된 CommonFileQuery에 따라 정렬됩니다.

public:
 virtual StorageFileQueryResult ^ CreateFileQuery(CommonFileQuery query) = CreateFileQuery;
/// [Windows.Foundation.Metadata.Overload("CreateFileQuery")]
StorageFileQueryResult CreateFileQuery(CommonFileQuery const& query);
[Windows.Foundation.Metadata.Overload("CreateFileQuery")]
public StorageFileQueryResult CreateFileQuery(CommonFileQuery query);
function createFileQuery(query)
Public Function CreateFileQuery (query As CommonFileQuery) As StorageFileQueryResult

매개 변수

query
CommonFileQuery

파일을 정렬하는 방법을 지정하고 쿼리가 단순하거나 깊은지 여부를 결정하는 열거형 값 중 하나입니다.

반환

쿼리 결과 개체입니다. 쿼리 결과의 GetFilesAsync 메서드를 호출하여 쿼리로 지정된 대로 정렬된 파일의 플랫 목록을 가져옵니다. 이 메서드는 IReadOnlyList<StorageFile 형식의 목록을 반환합니다>. 각 파일은 StorageFile 형식의 항목으로 표시됩니다.

구현

특성

예외

라이브러리 폴더가 아닌 폴더에 대한 xref:Windows.Storage.Search.CommonFileQuery?text=CommonFileQuery 열거형에서 <DefaultQuery> 이외의 값을 지정했습니다. 쿼리 값을 확인 합니다.

설명

CommonFileQuery는 특정 파일 특성(예: 제목 또는 날짜)을 기반으로 파일을 빠르고 쉽게 정렬합니다.

CommonFileQuery 열거형에서 DefaultQuery 옵션을 지정하면 이 쿼리는 현재 폴더의 파일만 반환하는 단순 쿼리입니다. CommonFileQuery 열거형에서 다른 값을 지정하면 이 쿼리는 현재 폴더와 하위 폴더에서 병합된 파일 목록을 반환하는 심층 쿼리입니다.

CommonFileQuery 열거형의 일부 값은 라이브러리 폴더(예: 사진 라이브러리) 또는 홈 그룹 폴더에서만 사용할 수 있습니다. DefaultQuery 옵션 외에도 OrderByNameOrderBySearchRank 옵션만 라이브러리 폴더가 아닌 폴더와 함께 사용할 수 있습니다.

단순 쿼리 및 심층 쿼리를 식별하는 메서드 목록은 GetFilesAsync 항목의 설명을 참조하세요.

특정 CommonFileQuery를 사용할 수 있는지 여부를 검사 폴더의 IsCommonFileQuerySupported 메서드를 호출합니다.

GetFilesAsync 메서드 중 하나를 호출하여 현재 폴더의 파일 목록을 비동기적으로 가져올 수도 있습니다.

Windows Server 2012의 경우 인덱서 구성 요소는 기본적으로 설치되지 않으므로 일부 CommonFileQuery 값을 사용하려면 인덱서 구성 요소를 설치해야 합니다.

추가 정보

적용 대상