Udostępnij za pośrednictwem


DownloadsFolder Class

Definition

Creates files and folders inside the Downloads folder.

public ref class DownloadsFolder abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class DownloadsFolder final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public static class DownloadsFolder
Public Class DownloadsFolder
Inheritance
Object Platform::Object IInspectable DownloadsFolder
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

You can create an empty file in the Downloads folder like this:

StorageFile file = await Windows.Storage.DownloadsFolder.CreateFileAsync("sample.txt");
// Process file

After createFileAsync completes, file gets the new file as a StorageFile.

Remarks

This class is static and cannot be instantiated. Call the methods directly instead.

File and folder permissions in the Downloads folder

All apps can create files and folders in the Downloads folder and can access the files that they create. But apps can't access files in the Downloads folder that they didn't create.

When your app creates a file in the Downloads folder, other apps can't interfere with or access your file unless the user explicitly gives the other app access. The user can give another app access to your file by selecting the file from the file picker. Your app can also use the file picker to get access to the files in the Downloads folder that it didn't create. Learn more about opening files with the file picker in Open files and folders with a picker.

Capabilities are not needed to create or access files in the Downloads folder. Learn more about capabilities in App capability declarations.

To learn more about what locations your app can access, see File access permissions.

Version history

Windows version SDK version Value added
1511 10586 CreateFileForUserAsync(User,String)
1511 10586 CreateFileForUserAsync(User,String,CreationCollisionOption)
1511 10586 CreateFolderForUserAsync(User,String)
1511 10586 CreateFolderForUserAsync(User,String,CreationCollisionOption)

Methods

CreateFileAsync(String, CreationCollisionOption)

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

CreateFileAsync(String)

Creates a new file inside the Downloads folder.

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.

CreateFolderAsync(String, CreationCollisionOption)

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

CreateFolderAsync(String)

Creates a new subfolder in the Downloads folder.

CreateFolderForUserAsync(User, String, CreationCollisionOption)

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

CreateFolderForUserAsync(User, String)

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

Applies to