IStorageFile
IStorageFile
IStorageFile
IStorageFile
Interface
Definition
Represents a file. Provides information about the file and its contents, and ways to manipulate them.
Important
If you simply want to work with files in your app, see the StorageFile class.
public : interface IStorageFilepublic interface IStorageFilePublic Interface IStorageFile// You can use this interface in JavaScript.
- Inheritance
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
musicLibrary
picturesLibrary
videosLibrary
documentsLibrary
|
Inherited Members
Inherited properties
Inherited methods
Properties
ContentType ContentType ContentType ContentType
Gets the MIME type of the contents of the file.
public : PlatForm::String ContentType { get; }public string ContentType { get; }Public ReadOnly Property ContentType As string// You can use this property in JavaScript.
- Value
- PlatForm::String string string string
The MIME type of the file contents.
For example, a music file might have the "audio/mpeg" MIME type.
FileType FileType FileType FileType
Gets the type (file name extension) of the file.
public : PlatForm::String FileType { get; }public string FileType { get; }Public ReadOnly Property FileType As string// You can use this property in JavaScript.
- Value
- PlatForm::String string string string
The file name extension of the file.
Methods
CopyAndReplaceAsync(IStorageFile) CopyAndReplaceAsync(IStorageFile) CopyAndReplaceAsync(IStorageFile) CopyAndReplaceAsync(IStorageFile)
Replaces the specified file with a copy of the current file.
public : IAsyncAction CopyAndReplaceAsync(IStorageFile fileToReplace)public IAsyncAction CopyAndReplaceAsync(IStorageFile fileToReplace)Public Function CopyAndReplaceAsync(fileToReplace As IStorageFile) As IAsyncAction// You can use this method in JavaScript.
- fileToReplace
- IStorageFile IStorageFile IStorageFile IStorageFile
The file to replace.
No object or value is returned when this method completes.
CopyAsync(IStorageFolder) CopyAsync(IStorageFolder) CopyAsync(IStorageFolder) CopyAsync(IStorageFolder)
Creates a copy of the file in the specified folder.
public : IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder)public IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder)Public Function CopyAsync(destinationFolder As IStorageFolder) As IAsyncOperation( Of StorageFile )// You can use this method in JavaScript.
- destinationFolder
- IStorageFolder IStorageFolder IStorageFolder IStorageFolder
The destination folder where the copy is created.
When this method completes, it returns a StorageFile that represents the copy.
CopyAsync(IStorageFolder, String) CopyAsync(IStorageFolder, String) CopyAsync(IStorageFolder, String) CopyAsync(IStorageFolder, String)
Creates a copy of the file in the specified folder, using the desired name.
public : IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder, PlatForm::String desiredNewName)public IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder, String desiredNewName)Public Function CopyAsync(destinationFolder As IStorageFolder, desiredNewName As String) As IAsyncOperation( Of StorageFile )// You can use this method in JavaScript.
- destinationFolder
- IStorageFolder IStorageFolder IStorageFolder IStorageFolder
The destination folder where the copy is created.
- desiredNewName
- PlatForm::String String String String
The desired name of the copy.
If there is an existing file in the destination folder that already has the specified desiredNewName, Windows generates a unique name for the copy.
When this method completes, it returns a StorageFile that represents the copy.
CopyAsync(IStorageFolder, String, NameCollisionOption) CopyAsync(IStorageFolder, String, NameCollisionOption) CopyAsync(IStorageFolder, String, NameCollisionOption) CopyAsync(IStorageFolder, String, NameCollisionOption)
Creates a copy of the file in the specified folder, using the desired name. This method also specifies what to do if an existing file in the specified folder has the same name.
public : IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder, PlatForm::String desiredNewName, NameCollisionOption option)public IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder, String desiredNewName, NameCollisionOption option)Public Function CopyAsync(destinationFolder As IStorageFolder, desiredNewName As String, option As NameCollisionOption) As IAsyncOperation( Of StorageFile )// You can use this method in JavaScript.
- destinationFolder
- IStorageFolder IStorageFolder IStorageFolder IStorageFolder
The destination folder where the copy is created.
- desiredNewName
- PlatForm::String String String String
The desired name of the copy.
If there is an existing file in the destination folder that already has the specified desiredNewName, the specified NameCollisionOption determines how Windows responds to the conflict.
An enum value that determines how Windows responds if the desiredNewName is the same as the name of an existing file in the destination folder.
When this method completes, it returns a StorageFile that represents the copy.
- See Also
MoveAndReplaceAsync(IStorageFile) MoveAndReplaceAsync(IStorageFile) MoveAndReplaceAsync(IStorageFile) MoveAndReplaceAsync(IStorageFile)
Moves the current file to the location of the specified file and replaces the specified file in that location.
public : IAsyncAction MoveAndReplaceAsync(IStorageFile fileToReplace)public IAsyncAction MoveAndReplaceAsync(IStorageFile fileToReplace)Public Function MoveAndReplaceAsync(fileToReplace As IStorageFile) As IAsyncAction// You can use this method in JavaScript.
- fileToReplace
- IStorageFile IStorageFile IStorageFile IStorageFile
The file to replace.
No object or value is returned by this method.
MoveAsync(IStorageFolder) MoveAsync(IStorageFolder) MoveAsync(IStorageFolder) MoveAsync(IStorageFolder)
Moves the current file to the specified folder.
public : IAsyncAction MoveAsync(IStorageFolder destinationFolder)public IAsyncAction MoveAsync(IStorageFolder destinationFolder)Public Function MoveAsync(destinationFolder As IStorageFolder) As IAsyncAction// You can use this method in JavaScript.
- destinationFolder
- IStorageFolder IStorageFolder IStorageFolder IStorageFolder
The destination folder where the file is moved.
This destination folder must be a physical location. Otherwise, if the destination folder exists only in memory, like a file group, this method fails and throws an exception.
No object or value is returned by this method.
MoveAsync(IStorageFolder, String) MoveAsync(IStorageFolder, String) MoveAsync(IStorageFolder, String) MoveAsync(IStorageFolder, String)
Moves the current file to the specified folder and renames the file according to the desired name.
public : IAsyncAction MoveAsync(IStorageFolder destinationFolder, PlatForm::String desiredNewName)public IAsyncAction MoveAsync(IStorageFolder destinationFolder, String desiredNewName)Public Function MoveAsync(destinationFolder As IStorageFolder, desiredNewName As String) As IAsyncAction// You can use this method in JavaScript.
- destinationFolder
- IStorageFolder IStorageFolder IStorageFolder IStorageFolder
The destination folder where the file is moved.
This destination folder must be a physical location. Otherwise, if the destination folder exists only in memory, like a file group, this method fails and throws an exception.
- desiredNewName
- PlatForm::String String String String
The desired name of the file after it is moved.
If there is an existing file in the destination folder that already has the specified desiredNewName, Windows generates a unique name for the file.
No object or value is returned by this method.
MoveAsync(IStorageFolder, String, NameCollisionOption) MoveAsync(IStorageFolder, String, NameCollisionOption) MoveAsync(IStorageFolder, String, NameCollisionOption) MoveAsync(IStorageFolder, String, NameCollisionOption)
Moves the current file to the specified folder and renames the file according to the desired name. This method also specifies what to do if a file with the same name already exists in the specified folder.
public : IAsyncAction MoveAsync(IStorageFolder destinationFolder, PlatForm::String desiredNewName, NameCollisionOption option)public IAsyncAction MoveAsync(IStorageFolder destinationFolder, String desiredNewName, NameCollisionOption option)Public Function MoveAsync(destinationFolder As IStorageFolder, desiredNewName As String, option As NameCollisionOption) As IAsyncAction// You can use this method in JavaScript.
- destinationFolder
- IStorageFolder IStorageFolder IStorageFolder IStorageFolder
The destination folder where the file is moved.
This destination folder must be a physical location. Otherwise, if the destination folder exists only in memory, like a file group, this method fails and throws an exception.
- desiredNewName
- PlatForm::String String String String
The desired name of the file after it is moved.
If there is an existing file in the destination folder that already has the specified desiredNewName, the specified NameCollisionOption determines how Windows responds to the conflict.
An enum value that determines how Windows responds if the desiredNewName is the same as the name of an existing file in the destination folder.
No object or value is returned by this method.
- See Also
OpenAsync(FileAccessMode) OpenAsync(FileAccessMode) OpenAsync(FileAccessMode) OpenAsync(FileAccessMode)
Opens a random-access stream over the file.
public : IAsyncOperation<IRandomAccessStream> OpenAsync(FileAccessMode accessMode)public IAsyncOperation<IRandomAccessStream> OpenAsync(FileAccessMode accessMode)Public Function OpenAsync(accessMode As FileAccessMode) As IAsyncOperation( Of IRandomAccessStream )// You can use this method in JavaScript.
- accessMode
- FileAccessMode FileAccessMode FileAccessMode FileAccessMode
The type of access to allow.
When this method completes, it returns the random-access stream (type IRandomAccessStream).
OpenTransactedWriteAsync() OpenTransactedWriteAsync() OpenTransactedWriteAsync() OpenTransactedWriteAsync()
Opens a transacted, random-access stream for writing to the file.
public : IAsyncOperation<StorageStreamTransaction> OpenTransactedWriteAsync()public IAsyncOperation<StorageStreamTransaction> OpenTransactedWriteAsync()Public Function OpenTransactedWriteAsync() As IAsyncOperation( Of StorageStreamTransaction )// You can use this method in JavaScript.
When this method completes, it returns a StorageStreamTransaction that contains the random-access stream and methods that can be used to complete transactions.