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 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 stringpublic string ContentType { get; }

    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 stringpublic string FileType { get; }

    Property Value

    • 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 IAsyncActionpublic IAsyncAction CopyAndReplaceAsync(IStorageFile fileToReplace)

    Parameters

    Returns

  • 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 )public IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder)

    Parameters

    Returns

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

    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(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, 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 )public IAsyncOperation<StorageFile> CopyAsync(IStorageFolder destinationFolder, String desiredNewName, NameCollisionOption option)

    Parameters

    Returns

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

  • 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 IAsyncActionpublic IAsyncAction MoveAndReplaceAsync(IStorageFile fileToReplace)

    Parameters

    Returns

  • 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 IAsyncActionpublic IAsyncAction MoveAsync(IStorageFolder destinationFolder)

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

    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(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, 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 IAsyncActionpublic IAsyncAction MoveAsync(IStorageFolder destinationFolder, String desiredNewName, NameCollisionOption option)

    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(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 )public IAsyncOperation<IRandomAccessStream> OpenAsync(FileAccessMode accessMode)

    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 )public IAsyncOperation<StorageStreamTransaction> OpenTransactedWriteAsync()

    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

documentsLibrary
musicLibrary
videosLibrary
picturesLibrary

Attributes

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

Details

Assembly

Windows.Storage.dll