DownloadsFolder.CreateFileForUserAsync 方法

定義

多載

CreateFileForUserAsync(User, String)

在特定 使用者的[下載] 資料夾內建立新的檔案。

CreateFileForUserAsync(User, String, CreationCollisionOption)

在特定 使用者的[下載] 資料夾中建立新的檔案,並指定如果 [下載] 資料夾中已有相同名稱的檔案,該怎麼做。

CreateFileForUserAsync(User, String)

在特定 使用者的[下載] 資料夾內建立新的檔案。

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

參數

user
User

建立檔案的使用者。

desiredName
String

Platform::String

winrt::hstring

要建立之檔案的所需名稱。

如果指定名稱的檔案已經存在,則會使用類似但唯一的名稱。 例如,如果 desiredName 是 「MyFileName.jpg」,而且該名稱的檔案已經存在 [下載] 資料夾中,則會改用 「MyFileName (1) .jpg」 之類的名稱來建立新檔案。

傳回

當這個方法完成時,它會以 StorageFile 物件的形式傳回新檔案。

屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10586.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v2.0 引進)

另請參閱

適用於

CreateFileForUserAsync(User, String, CreationCollisionOption)

在特定 使用者的[下載] 資料夾中建立新的檔案,並指定如果 [下載] 資料夾中已有相同名稱的檔案,該怎麼做。

public:
 static IAsyncOperation<StorageFile ^> ^ CreateFileForUserAsync(User ^ user, Platform::String ^ desiredName, CreationCollisionOption option);
/// [Windows.Foundation.Metadata.Overload("CreateFileForUserWithCollisionOptionAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<StorageFile> CreateFileForUserAsync(User const& user, winrt::hstring const& desiredName, CreationCollisionOption const& option);
[Windows.Foundation.Metadata.Overload("CreateFileForUserWithCollisionOptionAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<StorageFile> CreateFileForUserAsync(User user, string desiredName, CreationCollisionOption option);
function createFileForUserAsync(user, desiredName, option)
Public Shared Function CreateFileForUserAsync (user As User, desiredName As String, option As CreationCollisionOption) As IAsyncOperation(Of StorageFile)

參數

user
User

建立檔案的使用者。

desiredName
String

Platform::String

winrt::hstring

要建立之檔案的所需名稱。

如果目前資料夾中的現有檔案已經有指定的 desiredName,則指定的 CreationCollisionOption 會決定 Windows 如何回應衝突。

option
CreationCollisionOption

列舉值,決定 如果 desiredName 與目前資料夾中現有檔案的名稱相同,Windows 會如何回應。

因為應用程式只能存取指定 使用者之 Downloads 資料夾中的檔案,所以您無法指定 此參數的 OpenIfExistsReplaceExisting

傳回

當這個方法完成時,它會以 StorageFile 物件的形式傳回新檔案。

屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10586.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v2.0 引進)

另請參閱

適用於