StorageFile.GetFileFromPathForUserAsync(User, String) メソッド

定義

特定のユーザーのファイル システム内の絶対パスに基づいて StorageFile オブジェクトを取得します。

public:
 static IAsyncOperation<StorageFile ^> ^ GetFileFromPathForUserAsync(User ^ user, Platform::String ^ path);
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<StorageFile> GetFileFromPathForUserAsync(User const& user, winrt::hstring const& path);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<StorageFile> GetFileFromPathForUserAsync(User user, string path);
function getFileFromPathForUserAsync(user, path)
Public Shared Function GetFileFromPathForUserAsync (user As User, path As String) As IAsyncOperation(Of StorageFile)

パラメーター

user
User

StorageFile が返されるユーザー。

path
String

Platform::String

winrt::hstring

表す StorageFile を取得するファイルのパス。

パスでスラッシュを使用する場合は、円記号 (\) を使用してください。 スラッシュ (/) は、このメソッドでは受け入れできません。

戻り値

このメソッドが完了すると、 StorageFile としてファイルが返されます。

属性

Windows の要件

デバイス ファミリ
Windows 10, version 2004 (10.0.19041.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v10.0 で導入)

async Task<StorageFile> GetStorageFileAsync(User user, string path) {     
    // It is possible the file no longer exists     
    // or permissions were changed so that the     
    // app no longer has access to the path.     
    try     
    {         
        return await StorageFile.GetFileFromPathForUserAsync(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) です。

適用対象

こちらもご覧ください