StorageFolder.GetFolderFromPathForUserAsync(User, String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
根據指定使用者檔案系統中的絕對路徑取得 StorageFolder 。
public:
static IAsyncOperation<StorageFolder ^> ^ GetFolderFromPathForUserAsync(User ^ user, Platform::String ^ path);
/// [Windows.Foundation.Metadata.RemoteAsync]
static IAsyncOperation<StorageFolder> GetFolderFromPathForUserAsync(User const& user, winrt::hstring const& path);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<StorageFolder> GetFolderFromPathForUserAsync(User user, string path);
function getFolderFromPathForUserAsync(user, path)
Public Shared Function GetFolderFromPathForUserAsync (user As User, path As String) As IAsyncOperation(Of StorageFolder)
參數
- user
- User
傳回 StorageFolder的使用者。
- path
-
String
Platform::String
winrt::hstring
檔案系統中的絕對路徑 (不是要取得之資料夾的 Uri) 。
傳回
當這個方法成功完成時,它會傳回代表使用者指定資料夾的 StorageFolder 。
- 屬性
Windows 需求
裝置系列 |
Windows 10, version 2004 (已於 10.0.19041.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v10.0 引進)
|
範例
async Task<StorageFolder> GetStorageFolderAsync(User user, string path) {
// It is possible the folder no longer exists
// or permissions were changed so that the
// app no longer has access to the path.
try
{
return await StorageFolder.GetFolderFromPathForUserAsync(user, path);
}
catch( System.IO.IOException ex )
{
// File, or path not found I/O Exceptions can happen
// notify user or implement fallback, etc...
string message = ex.Message;
return null;
}
catch(System.UnauthorizedAccessException ex)
{
// Access denied - notify user or implement fallback, etc...
string message = ex.Message;
return null;
}
備註
此方法是多使用者感知 (MUA) 。