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 IStorageFile : IStorageItem, IInputStreamReference, IRandomAccessStreamReference
public interface IStorageFile : IStorageItem, IInputStreamReference, IRandomAccessStreamReference
Public Interface IStorageFile Implements IStorageItem, IInputStreamReference, IRandomAccessStreamReference
// You can't instantiate an interface directly in JavaScript. You can use objects that implement the interface, however.
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
musicLibrary picturesLibrary videosLibrary documentsLibrary

Properties

Attributes Attributes Attributes Attributes

Inherited from IStorageItem

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
var string = iStorageFile.contentType;
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.

DateCreated DateCreated DateCreated DateCreated

Inherited from IStorageItem

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
var string = iStorageFile.fileType;
Value
Platform::String string string string

The file name extension of the file.

Name Name Name Name

Inherited from IStorageItem

Path Path Path Path

Inherited from IStorageItem

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
Windows.Storage.IStorageFile.copyAndReplaceAsync(fileToReplace).done( /* Your success and error handlers */ );
Parameters
fileToReplace
IStorageFile IStorageFile IStorageFile IStorageFile

The file to replace.

Returns

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 )
Windows.Storage.IStorageFile.copyAsync(destinationFolder).done( /* Your success and error handlers */ );
Parameters
destinationFolder
IStorageFolder IStorageFolder IStorageFolder IStorageFolder

The destination folder where the copy is created.

Returns
See Also

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 )
Windows.Storage.IStorageFile.copyAsync(destinationFolder, desiredNewName).done( /* Your success and error handlers */ );
Parameters
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.

Returns
See Also

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 )
Windows.Storage.IStorageFile.copyAsync(destinationFolder, desiredNewName, option).done( /* Your success and error handlers */ );
Parameters
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.

option
NameCollisionOption 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
See Also

DeleteAsync DeleteAsync DeleteAsync DeleteAsync

Inherited from IStorageItem

DeleteAsync(StorageDeleteOption) DeleteAsync(StorageDeleteOption) DeleteAsync(StorageDeleteOption) DeleteAsync(StorageDeleteOption)

Inherited from IStorageItem

GetBasicPropertiesAsync GetBasicPropertiesAsync GetBasicPropertiesAsync GetBasicPropertiesAsync

Inherited from IStorageItem

IsOfType(StorageItemTypes) IsOfType(StorageItemTypes) IsOfType(StorageItemTypes) IsOfType(StorageItemTypes)

Inherited from IStorageItem

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
Windows.Storage.IStorageFile.moveAndReplaceAsync(fileToReplace).done( /* Your success and error handlers */ );
Parameters
fileToReplace
IStorageFile IStorageFile IStorageFile IStorageFile

The file to replace.

Returns

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
Windows.Storage.IStorageFile.moveAsync(destinationFolder).done( /* Your success and error handlers */ );
Parameters
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.

Returns

No object or value is returned by this method.

See Also

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
Windows.Storage.IStorageFile.moveAsync(destinationFolder, desiredNewName).done( /* Your success and error handlers */ );
Parameters
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.

Returns

No object or value is returned by this method.

See Also

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
Windows.Storage.IStorageFile.moveAsync(destinationFolder, desiredNewName, option).done( /* Your success and error handlers */ );
Parameters
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.

option
NameCollisionOption 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.

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 )
Windows.Storage.IStorageFile.openAsync(accessMode).done( /* Your success and error handlers */ );
Parameters
accessMode
FileAccessMode FileAccessMode FileAccessMode FileAccessMode

The type of access to allow.

Returns

OpenReadAsync OpenReadAsync OpenReadAsync OpenReadAsync

OpenSequentialReadAsync OpenSequentialReadAsync OpenSequentialReadAsync OpenSequentialReadAsync

Inherited from IInputStreamReference

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 )
Windows.Storage.IStorageFile.openTransactedWriteAsync().done( /* Your success and error handlers */ );
Returns

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

RenameAsync(String) RenameAsync(String) RenameAsync(String) RenameAsync(String)

Inherited from IStorageItem

RenameAsync(String,NameCollisionOption) RenameAsync(String,NameCollisionOption) RenameAsync(String,NameCollisionOption) RenameAsync(String,NameCollisionOption)

Inherited from IStorageItem

See Also