Delen via


StorageFolder.GetFolderFromPathForUserAsync(User, String) Method

Definition

Gets the StorageFolder based on an absolute path in the file system for a given user.

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)

Parameters

user
User

The User for which the StorageFolder is returned.

path
String

Platform::String

winrt::hstring

The absolute path in the file system (not the Uri) of the folder to get.

Returns

When this method completes successfully, it returns a StorageFolder that represents the specified folder for the user.

Attributes

Windows requirements

Device family
Windows 10, version 2004 (introduced in 10.0.19041.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v10.0)

Examples

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;
    }

Remarks

This method is Multi-User Aware (MUA).

Applies to

See also