StorageFolder.GetFolderFromPathForUserAsync(User, String) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan StorageFolder berdasarkan jalur absolut dalam sistem file untuk pengguna tertentu.
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)
Parameter
- user
- User
Pengguna tempat StorageFolder dikembalikan.
- path
-
String
Platform::String
winrt::hstring
Jalur absolut dalam sistem file (bukan Uri) folder yang akan didapatkan.
Mengembalikan
Ketika metode ini berhasil diselesaikan, metode ini mengembalikan StorageFolder yang mewakili folder yang ditentukan untuk pengguna.
- Atribut
Persyaratan Windows
Rangkaian perangkat |
Windows 10, version 2004 (diperkenalkan dalam 10.0.19041.0)
|
API contract |
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v10.0)
|
Contoh
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;
}
Keterangan
Metode ini adalah Multi-User Aware (MUA).