Dela via


DownloadsFolder.CreateFileForUserAsync Method

Definition

Overloads

CreateFileForUserAsync(User, String)

Creates a new file inside the Downloads folder of a specific User.

CreateFileForUserAsync(User, String, CreationCollisionOption)

Creates a new file in the Downloads folder of a specific User, and specifies what to do if a file with the same name already exists in the Downloads folder.

CreateFileForUserAsync(User, String)

Creates a new file inside the Downloads folder of a specific User.

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)

Parameters

user
User

The User for which the file is created.

desiredName
String

Platform::String

winrt::hstring

The desired name of the file to create.

If a file with the specified name already exists, a similar but unique name will be used. For example, if desiredName is "MyFileName.jpg" and a file by that name already exists in the Downloads folder, the new file will be created with a name like "MyFileName (1).jpg" instead.

Returns

When this method completes, it returns the new file as a StorageFile object.

Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v2.0)

See also

Applies to

CreateFileForUserAsync(User, String, CreationCollisionOption)

Creates a new file in the Downloads folder of a specific User, and specifies what to do if a file with the same name already exists in the Downloads folder.

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)

Parameters

user
User

The User for which the file is created.

desiredName
String

Platform::String

winrt::hstring

The desired name of the file to create.

If there is an existing file in the current folder that already has the specified desiredName, the specified CreationCollisionOption determines how Windows responds to the conflict.

option
CreationCollisionOption

The enum value that determines how Windows responds if the desiredName is the same as the name of an existing file in the current folder.

Because the app can only access files in the Downloads folder of the specified User, you can't specify OpenIfExists or ReplaceExisting for this parameter.

Returns

When this method completes, it returns the new file as a StorageFile object.

Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v2.0)

See also

Applies to