DownloadsFolder DownloadsFolder DownloadsFolder DownloadsFolder Class

Creates files and folders inside the Downloads folder.

Syntax

Declaration

public static class DownloadsFolderpublic static class DownloadsFolderPublic Static Class DownloadsFolderpublic static class DownloadsFolder

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.

Examples

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

Windows.Storage.DownloadsFolder.createFileAsync("sample.txt").done(
    function (file) {
        // Process file
    }
);
StorageFile file = await Windows.Storage.DownloadsFolder.CreateFileAsync("sample.txt");
// Process file

After CreateFileAsync(String, CreationCollisionOption) completes, file gets the new file as a StorageFile.

Methods summary

Creates a new file inside the Downloads folder.

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.

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

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.

Creates a new subfolder in the Downloads folder.

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.

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

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.

Methods

  • CreateFileAsync(String)
    CreateFileAsync(String)
    CreateFileAsync(String)
    CreateFileAsync(String)

    Creates a new file inside the Downloads folder.

    public static IAsyncOperation<StorageFile> CreateFileAsync(String desiredName)public static IAsyncOperation<StorageFile> CreateFileAsync(String desiredName)Public Static Function CreateFileAsync(desiredName As String) As IAsyncOperation( Of StorageFile )public static IAsyncOperation<StorageFile> CreateFileAsync(String desiredName)

    Parameters

    • desiredName
      System.String
      System.String
      System.String
      System.String

      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.

  • CreateFileAsync(String, CreationCollisionOption)
    CreateFileAsync(String, CreationCollisionOption)
    CreateFileAsync(String, CreationCollisionOption)
    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.

    public static IAsyncOperation<StorageFile> CreateFileAsync(String desiredName, CreationCollisionOption option)public static IAsyncOperation<StorageFile> CreateFileAsync(String desiredName, CreationCollisionOption option)Public Static Function CreateFileAsync(desiredName As String, option As CreationCollisionOption) As IAsyncOperation( Of StorageFile )public static IAsyncOperation<StorageFile> CreateFileAsync(String desiredName, CreationCollisionOption option)

    Parameters

    Returns

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

  • CreateFileForUserAsync(User, String)
    CreateFileForUserAsync(User, String)
    CreateFileForUserAsync(User, String)
    CreateFileForUserAsync(User, String)

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

    public static IAsyncOperation<StorageFile> CreateFileForUserAsync(User user, String desiredName)public static IAsyncOperation<StorageFile> CreateFileForUserAsync(User user, String desiredName)Public Static Function CreateFileForUserAsync(user As User, desiredName As String) As IAsyncOperation( Of StorageFile )public static IAsyncOperation<StorageFile> CreateFileForUserAsync(User user, String desiredName)

    Parameters

    • user

      The User for which the file is created.

    • desiredName
      System.String
      System.String
      System.String
      System.String

      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.

  • CreateFileForUserAsync(User, String, CreationCollisionOption)
    CreateFileForUserAsync(User, String, CreationCollisionOption)
    CreateFileForUserAsync(User, String, CreationCollisionOption)
    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, String desiredName, CreationCollisionOption option)public static IAsyncOperation<StorageFile> CreateFileForUserAsync(User user, String desiredName, CreationCollisionOption option)Public Static Function CreateFileForUserAsync(user As User, desiredName As String, option As CreationCollisionOption) As IAsyncOperation( Of StorageFile )public static IAsyncOperation<StorageFile> CreateFileForUserAsync(User user, String desiredName, CreationCollisionOption option)

    Parameters

    Returns

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

  • CreateFolderAsync(String)
    CreateFolderAsync(String)
    CreateFolderAsync(String)
    CreateFolderAsync(String)

    Creates a new subfolder in the Downloads folder.

    public static IAsyncOperation<StorageFolder> CreateFolderAsync(String desiredName)public static IAsyncOperation<StorageFolder> CreateFolderAsync(String desiredName)Public Static Function CreateFolderAsync(desiredName As String) As IAsyncOperation( Of StorageFolder )public static IAsyncOperation<StorageFolder> CreateFolderAsync(String desiredName)

    Parameters

    • desiredName
      System.String
      System.String
      System.String
      System.String

      The desired name of the subfolder to create.

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

    Returns

    • When this method completes, it returns the new subfolder as a StorageFolder.

  • CreateFolderAsync(String, CreationCollisionOption)
    CreateFolderAsync(String, CreationCollisionOption)
    CreateFolderAsync(String, CreationCollisionOption)
    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.

    public static IAsyncOperation<StorageFolder> CreateFolderAsync(String desiredName, CreationCollisionOption option)public static IAsyncOperation<StorageFolder> CreateFolderAsync(String desiredName, CreationCollisionOption option)Public Static Function CreateFolderAsync(desiredName As String, option As CreationCollisionOption) As IAsyncOperation( Of StorageFolder )public static IAsyncOperation<StorageFolder> CreateFolderAsync(String desiredName, CreationCollisionOption option)

    Parameters

    Returns

    • When this method completes, it returns the new subfolder as a StorageFolder.

  • CreateFolderForUserAsync(User, String)
    CreateFolderForUserAsync(User, String)
    CreateFolderForUserAsync(User, String)
    CreateFolderForUserAsync(User, String)

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

    public static IAsyncOperation<StorageFolder> CreateFolderForUserAsync(User user, String desiredName)public static IAsyncOperation<StorageFolder> CreateFolderForUserAsync(User user, String desiredName)Public Static Function CreateFolderForUserAsync(user As User, desiredName As String) As IAsyncOperation( Of StorageFolder )public static IAsyncOperation<StorageFolder> CreateFolderForUserAsync(User user, String desiredName)

    Parameters

    • user

      The User for which the folder is created.

    • desiredName
      System.String
      System.String
      System.String
      System.String

      The desired name of the subfolder to create.

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

    Returns

    • When this method completes, it returns the new subfolder as a StorageFolder.

  • CreateFolderForUserAsync(User, String, CreationCollisionOption)
    CreateFolderForUserAsync(User, String, CreationCollisionOption)
    CreateFolderForUserAsync(User, String, CreationCollisionOption)
    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.

    public static IAsyncOperation<StorageFolder> CreateFolderForUserAsync(User user, String desiredName, CreationCollisionOption option)public static IAsyncOperation<StorageFolder> CreateFolderForUserAsync(User user, String desiredName, CreationCollisionOption option)Public Static Function CreateFolderForUserAsync(user As User, desiredName As String, option As CreationCollisionOption) As IAsyncOperation( Of StorageFolder )public static IAsyncOperation<StorageFolder> CreateFolderForUserAsync(User user, String desiredName, CreationCollisionOption option)

    Parameters

    Returns

    • When this method completes, it returns the new subfolder as a StorageFolder.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.StaticAttribute

Details

Assembly

Windows.Storage.dll