StorageFolder.GetFolderFromPathAsync(String) 메서드

정의

파일 시스템에서 지정된 절대 경로가 있는 폴더를 가져옵니다.

public:
 static IAsyncOperation<StorageFolder ^> ^ GetFolderFromPathAsync(Platform::String ^ path);
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<StorageFolder> GetFolderFromPathAsync(winrt::hstring const& path);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<StorageFolder> GetFolderFromPathAsync(string path);
function getFolderFromPathAsync(path)
Public Shared Function GetFolderFromPathAsync (path As String) As IAsyncOperation(Of StorageFolder)

매개 변수

path
String

Platform::String

winrt::hstring

가져올 폴더의 파일 시스템(Uri 아님)의 절대 경로입니다.

경로에서 슬래시를 사용하는 경우 백슬라이쉬(\)를 사용해야 합니다. 슬래시(/)는 이 메서드에서 허용되지 않습니다.

반환

이 메서드가 성공적으로 완료되면 지정된 폴더를 나타내는 StorageFolder 를 반환합니다.

특성

예외

지정된 폴더가 없습니다. 경로 값을 확인 합니다.

지정된 폴더에 액세스할 수 있는 권한이 없습니다. 자세한 내용은 파일 액세스 권한을 참조하세요.

경로는 상대 경로 또는 URI일 수 없습니다. 경로 값을 확인 합니다.

예제

다음 예제에서는 GetFolderFromPathAsync 메서드를 호출하여 파일 시스템에서 지정된 절대 경로가 있는 폴더를 가져오는 방법을 보여줍니다.

using Windows.Storage;
using System.Threading.Tasks;

// Get the path to the app's Assets folder.
string root = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
string path = root + @"\Assets";

// Get the folder object that corresponds to this absolute path in the file system.
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(path);
IAsyncAction MainPage::ExampleCoroutineAsync()
{
    // Get the path to the app's Assets folder.
    std::wstring path{ Windows::ApplicationModel::Package::Current().InstalledLocation().Path() + L"\\Assets" };

    // Get the folder object that corresponds to this absolute path in the file system.
    Windows::Storage::StorageFolder folder{ co_await Windows::Storage::StorageFolder::GetFolderFromPathAsync(path) };
    ::OutputDebugString(folder.Name().c_str());
}
// Get the path to the app's installation folder.
String^ root = Windows::ApplicationModel::Package::Current->InstalledLocation->Path;

// Get the folder object that corresponds to
// this absolute path in the file system.
create_task(StorageFolder::GetFolderFromPathAsync(root)).then([=](StorageFolder^ folder){
 String^ output = folder->Name;
 OutputDebugString(output->Begin());
});

적용 대상

추가 정보