IStorageFile IStorageFile IStorageFile IStorageFile Interface

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.

Syntax

Declaration

public interface IStorageFilepublic interface IStorageFilePublic Interface IStorageFile

Inheritance Hierarchy

Properties summary

Gets the MIME type of the contents of the file.

Gets the type (file name extension) of the file.

Methods summary

Replaces the specified file with a copy of the current file.

Creates a copy of the file in the specified folder.

Creates a copy of the file in the specified folder, using the desired name.

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.

Moves the current file to the location of the specified file and replaces the specified file in that location.

Moves the current file to the specified folder.

Moves the current file to the specified folder and renames the file according to the desired name.

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.

Opens a random-access stream over the file.

Opens a transacted, random-access stream for writing to the file.

Properties

  • ContentType
    ContentType
    ContentType
    ContentType

    Gets the MIME type of the contents of the file.

    public string ContentType { get; }public string ContentType { get; }Public ReadOnly Property ContentType As string

    Property Value

    • 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 string FileType { get; }public string FileType { get; }Public ReadOnly Property FileType As string

    Property Value

    • string
      string
      string
      string

      The file name extension of the file.

Methods

  • CopyAndReplaceAsync(Windows.Storage.IStorageFile)
    CopyAndReplaceAsync(Windows.Storage.IStorageFile)
    CopyAndReplaceAsync(Windows.Storage.IStorageFile)
    CopyAndReplaceAsync(Windows.Storage.IStorageFile)

    Replaces the specified file with a copy of the current file.

    public IAsyncAction CopyAndReplaceAsync(Windows.Storage.IStorageFile)public IAsyncAction CopyAndReplaceAsync(Windows.Storage.IStorageFile)Public Function CopyAndReplaceAsync(Windows.Storage.IStorageFile) As IAsyncAction

    Parameters

    Returns

  • CopyAsync(Windows.Storage.IStorageFolder)
    CopyAsync(Windows.Storage.IStorageFolder)
    CopyAsync(Windows.Storage.IStorageFolder)
    CopyAsync(Windows.Storage.IStorageFolder)

    Creates a copy of the file in the specified folder.

    public IAsyncOperation<StorageFile> CopyAsync(Windows.Storage.IStorageFolder)public IAsyncOperation<StorageFile> CopyAsync(Windows.Storage.IStorageFolder)Public Function CopyAsync(Windows.Storage.IStorageFolder) As IAsyncOperation( Of StorageFile )

    Parameters

    Returns

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

  • CopyAsync(Windows.Storage.IStorageFolder,System.String)
    CopyAsync(Windows.Storage.IStorageFolder,System.String)
    CopyAsync(Windows.Storage.IStorageFolder,System.String)
    CopyAsync(Windows.Storage.IStorageFolder,System.String)

    Creates a copy of the file in the specified folder, using the desired name.

    public IAsyncOperation<StorageFile> CopyAsync(Windows.Storage.IStorageFolder,System.String)public IAsyncOperation<StorageFile> CopyAsync(Windows.Storage.IStorageFolder,System.String)Public Function CopyAsync(Windows.Storage.IStorageFolder,System.String) As IAsyncOperation( Of StorageFile )

    Parameters

    • destinationFolder

      The destination folder where the copy is created.

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

  • CopyAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)
    CopyAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)
    CopyAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)
    CopyAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.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(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)public IAsyncOperation<StorageFile> CopyAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)Public Function CopyAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption) As IAsyncOperation( Of StorageFile )

    Parameters

    Returns

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

  • MoveAndReplaceAsync(Windows.Storage.IStorageFile)
    MoveAndReplaceAsync(Windows.Storage.IStorageFile)
    MoveAndReplaceAsync(Windows.Storage.IStorageFile)
    MoveAndReplaceAsync(Windows.Storage.IStorageFile)

    Moves the current file to the location of the specified file and replaces the specified file in that location.

    public IAsyncAction MoveAndReplaceAsync(Windows.Storage.IStorageFile)public IAsyncAction MoveAndReplaceAsync(Windows.Storage.IStorageFile)Public Function MoveAndReplaceAsync(Windows.Storage.IStorageFile) As IAsyncAction

    Parameters

    Returns

  • MoveAsync(Windows.Storage.IStorageFolder)
    MoveAsync(Windows.Storage.IStorageFolder)
    MoveAsync(Windows.Storage.IStorageFolder)
    MoveAsync(Windows.Storage.IStorageFolder)

    Moves the current file to the specified folder.

    public IAsyncAction MoveAsync(Windows.Storage.IStorageFolder)public IAsyncAction MoveAsync(Windows.Storage.IStorageFolder)Public Function MoveAsync(Windows.Storage.IStorageFolder) As IAsyncAction

    Parameters

    • destinationFolder

      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

  • MoveAsync(Windows.Storage.IStorageFolder,System.String)
    MoveAsync(Windows.Storage.IStorageFolder,System.String)
    MoveAsync(Windows.Storage.IStorageFolder,System.String)
    MoveAsync(Windows.Storage.IStorageFolder,System.String)

    Moves the current file to the specified folder and renames the file according to the desired name.

    public IAsyncAction MoveAsync(Windows.Storage.IStorageFolder,System.String)public IAsyncAction MoveAsync(Windows.Storage.IStorageFolder,System.String)Public Function MoveAsync(Windows.Storage.IStorageFolder,System.String) As IAsyncAction

    Parameters

    • destinationFolder

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

  • MoveAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)
    MoveAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)
    MoveAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)
    MoveAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.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(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)public IAsyncAction MoveAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption)Public Function MoveAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption) As IAsyncAction

    Parameters

    • destinationFolder

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

      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

  • OpenAsync(Windows.Storage.FileAccessMode)
    OpenAsync(Windows.Storage.FileAccessMode)
    OpenAsync(Windows.Storage.FileAccessMode)
    OpenAsync(Windows.Storage.FileAccessMode)

    Opens a random-access stream over the file.

    public IAsyncOperation<IRandomAccessStream> OpenAsync(Windows.Storage.FileAccessMode)public IAsyncOperation<IRandomAccessStream> OpenAsync(Windows.Storage.FileAccessMode)Public Function OpenAsync(Windows.Storage.FileAccessMode) As IAsyncOperation( Of IRandomAccessStream )

    Parameters

    Returns

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

    Returns

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

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Capabilities

picturesLibrary
videosLibrary
musicLibrary
documentsLibrary

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.GuidAttribute

Details

Assembly

Windows.Storage.dll