I​Storage​File I​Storage​File I​Storage​File 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
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
documentsLibrary musicLibrary videosLibrary picturesLibrary

Inherited Members

Inherited properties

Inherited methods

Properties

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
Value
string string string

The MIME type of the file contents.

For example, a music file might have the "audio/mpeg" MIME type.

Attributes

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
Value
string string string

The file name extension of the file.

Attributes

Methods

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
Parameters
fileToReplace
IStorageFile IStorageFile IStorageFile

The file to replace.

Returns

No object or value is returned when this method completes.

Attributes

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 )
Parameters
destinationFolder
IStorageFolder IStorageFolder IStorageFolder

The destination folder where the copy is created.

Returns

When this method completes, it returns a StorageFile that represents the copy.

Attributes

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, String desiredNewName)public IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder, String desiredNewName)Public Function CopyAsync(destinationFolder As IStorageFolder, desiredNewName As String) As IAsyncOperation( Of StorageFile )
Parameters
destinationFolder
IStorageFolder IStorageFolder IStorageFolder

The destination folder where the copy is created.

desiredNewName
System.String System.String System.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.

Returns

When this method completes, it returns a StorageFile that represents the copy.

Attributes

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, 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 )
Parameters
destinationFolder
IStorageFolder IStorageFolder IStorageFolder

The destination folder where the copy is created.

desiredNewName
System.String System.String System.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.

option
NameCollisionOption NameCollisionOption NameCollisionOption

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.

Returns

When this method completes, it returns a StorageFile that represents the copy.

Attributes

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
Parameters
fileToReplace
IStorageFile IStorageFile IStorageFile

The file to replace.

Returns

No object or value is returned by this method.

Attributes

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
Parameters
destinationFolder
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.

Returns

No object or value is returned by this method.

Attributes

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, String desiredNewName)public IAsyncAction MoveAsync(IStorageFolder destinationFolder, String desiredNewName)Public Function MoveAsync(destinationFolder As IStorageFolder, desiredNewName As String) As IAsyncAction
Parameters
destinationFolder
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
System.String System.String System.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.

Returns

No object or value is returned by this method.

Attributes

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, 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
Parameters
destinationFolder
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
System.String System.String System.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.

option
NameCollisionOption NameCollisionOption NameCollisionOption

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.

Returns

No object or value is returned by this method.

Attributes

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 )
Parameters
accessMode
FileAccessMode FileAccessMode FileAccessMode

The type of access to allow.

Returns

When this method completes, it returns the random-access stream (type IRandomAccessStream).

Attributes

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 )
Returns

When this method completes, it returns a StorageStreamTransaction that contains the random-access stream and methods that can be used to complete transactions.

Attributes