DownloadsFolder
DownloadsFolder
DownloadsFolder
DownloadsFolder
Class
Definition
Creates files and folders inside the Downloads folder.
public : static class DownloadsFolderpublic static class DownloadsFolderPublic Static Class DownloadsFolder// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
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 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.
Methods
CreateFileAsync(String) CreateFileAsync(String) CreateFileAsync(String) CreateFileAsync(String)
Creates a new file inside the Downloads folder.
public : static IAsyncOperation<StorageFile> CreateFileAsync(PlatForm::String desiredName)public static IAsyncOperation<StorageFile> CreateFileAsync(String desiredName)Public Static Function CreateFileAsync(desiredName As String) As IAsyncOperation( Of StorageFile )// You can use this method in JavaScript.
- desiredName
- PlatForm::String String String 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.
When this method completes, it returns the new file as a StorageFile object.
- See Also
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(PlatForm::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 )// You can use this method in JavaScript.
- desiredName
- PlatForm::String String String String
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 CreationCollisionOption CreationCollisionOption 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 that it created, you can't specify OpenIfExists or ReplaceExisting for this parameter.
When this method completes, it returns the new file as a StorageFile object.
- See Also
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, PlatForm::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 )// You can use this method in JavaScript.
- desiredName
- PlatForm::String String String 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.
When this method completes, it returns the new file as a StorageFile object.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
- See Also
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, PlatForm::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 )// You can use this method in JavaScript.
- desiredName
- PlatForm::String String String String
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 CreationCollisionOption CreationCollisionOption 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.
When this method completes, it returns the new file as a StorageFile object.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
- See Also
CreateFolderAsync(String) CreateFolderAsync(String) CreateFolderAsync(String) CreateFolderAsync(String)
Creates a new subfolder in the Downloads folder.
public : static IAsyncOperation<StorageFolder> CreateFolderAsync(PlatForm::String desiredName)public static IAsyncOperation<StorageFolder> CreateFolderAsync(String desiredName)Public Static Function CreateFolderAsync(desiredName As String) As IAsyncOperation( Of StorageFolder )// You can use this method in JavaScript.
- desiredName
- PlatForm::String String String 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.
When this method completes, it returns the new subfolder as a StorageFolder.
- See Also
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(PlatForm::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 )// You can use this method in JavaScript.
- desiredName
- PlatForm::String String String String
The desired name of the subfolder to create.
If there is an existing subfolder in the Downloads folder that already has the specified desiredName, the specified CreationCollisionOption determines how Windows responds to the conflict.
- option
- CreationCollisionOption CreationCollisionOption CreationCollisionOption CreationCollisionOption
The enum value that determines how Windows responds if the desiredName is the same as the name of an existing subfolder in the Downloads folder.
Because the app can only access folders in the Downloads folder that it created, you can't specify OpenIfExists or ReplaceExisting for this parameter.
When this method completes, it returns the new subfolder as a StorageFolder.
- See Also
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, PlatForm::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 )// You can use this method in JavaScript.
- desiredName
- PlatForm::String String String 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.
When this method completes, it returns the new subfolder as a StorageFolder.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
- See Also
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, PlatForm::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 )// You can use this method in JavaScript.
- desiredName
- PlatForm::String String String String
The desired name of the subfolder to create.
If there is an existing subfolder in the Downloads folder that already has the specified desiredName, the specified CreationCollisionOption determines how Windows responds to the conflict.
- option
- CreationCollisionOption CreationCollisionOption CreationCollisionOption CreationCollisionOption
The enum value that determines how Windows responds if the desiredName is the same as the name of an existing subfolder in the Downloads folder.
Because the app can only access folders in the Downloads folder of the specified User, you can't specify OpenIfExists or ReplaceExisting for this parameter.
When this method completes, it returns the new subfolder as a StorageFolder.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
- See Also