DownloadsFolder.CreateFileAsync 方法

定義

多載

CreateFileAsync(String)

在 [下載] 資料夾內建立新的檔案。

CreateFileAsync(String, CreationCollisionOption)

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

CreateFileAsync(String)

在 [下載] 資料夾內建立新的檔案。

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

參數

desiredName
String

Platform::String

winrt::hstring

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

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

傳回

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

屬性

另請參閱

適用於

CreateFileAsync(String, CreationCollisionOption)

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

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

參數

desiredName
String

Platform::String

winrt::hstring

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

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

option
CreationCollisionOption

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

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

傳回

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

屬性

另請參閱

適用於