StorageFile StorageFile StorageFile StorageFile Class

Represents a file. Provides information about the file and its content, and ways to manipulate them.

Syntax

Declaration

public sealed class StorageFilepublic sealed class StorageFilePublic NotInheritable Class StorageFile

Remarks

Typically, you access StorageFile objects as the result of asynchronous method and/or function calls. For example, both of the static methods GetFileFromPathAsync(System.String) and GetFileFromApplicationUriAsync(Windows.Foundation.Uri) return a StorageFile that represents the specified file.

Additionally, whenever you call a file picker to let the user pick a file (or files) the file picker will return the file as a StorageFile.

Note

StorageFile objects can't represent files that are ".lnk", ".url", or ".wsh" file types.

Examples

This example shows you how to call a file picker, using PickSingleFileAsync() to capture and process a file that the users picks.

StorageFile file = await openPicker.PickSingleFileAsync();
// Process picked file
if (file != null)
{
    // Store file for future access
    fileToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file);
}
else
{
    // The user didn't pick a file
}

openPicker.pickSingleFileAsync().then(function (file) {
   if (file) {
       // Process picked file

       // Store file for future access
       var fileToken = Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList.add(file);
   } else {
       // The user didn't pick a file
   }
});

After PickSingleFileAsync() completes, file gets the picked file as a StorageFile.

In the example, openPicker contains a FileOpenPicker object. To learn more about using file picker see Open files and folders with a picker.

Additionally, fileToken gets an identifier that you can use to retrieve the file from the FutureAccessList. To learn more about storing files and folders so you can access them again later, see FutureAccessList, MostRecentlyUsedList and How to track recently used files and folders.

Properties summary

Gets the attributes of a file.

Gets the MIME type of the contents of the file.

Gets the date and time when the current file was created.

Gets a user-friendly name for the file.

Gets a user-friendly description of the type of the file.

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

Gets an identifier for the file. This ID is unique for the query result or StorageFolder that contains the file and can be used to distinguish between items that have the same name.

Indicates if the file is local, is cached locally, or can be downloaded.

Gets the name of the file including the file name extension.

Gets the full file-system path of the current file, if the file has a path.

Gets an object that provides access to the content-related properties of the file.

Gets the StorageProvider object that contains info about the service that stores the current 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 and renames the copy.

Creates a copy of the file in the specified folder and renames the copy. This method also specifies what to do if a file with the same name already exists in the destination folder.

Creates a StorageFile to represent the specified stream of data. This method lets the app produce the data on-demand by specifying a function to be invoked when the StorageFile that represents the stream is first accessed.

Creates a StorageFile to represent a stream of data from the specified Uniform Resource Identifier (URI) resource. This method lets the app download the data on-demand when the StorageFile that represents the stream is first accessed.

Deletes the current file.

Deletes the current file, optionally deleting the item permanently.

Gets the basic properties of the current file.

Gets a StorageFile object to represent the specified Uniform Resource Identifier (URI) app resource. For examples of sample URIs see How to load file resources.

Gets a StorageFile object to represent the file at the specified path.

Gets the parent folder of the current file.

Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail.

Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail and the requested size.

Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail, the requested size, and the specified options

Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail.

Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail and the requested size.

Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail, the requested size, and the specified options.

Indicates whether the current file is equal to the specified file.

Determines whether the current StorageFile matches the specified StorageItemTypes value.

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 with the specified options over the specified file.

Opens a random-access stream with the specified options over the specified file.

Opens a random-access stream over the current file for reading file contents.

Opens a sequential-access stream over the current file for reading file contents.

Opens a random-access stream to the file that can be used for transacted-write operations.

Opens a random-access stream to the file that can be used for transacted-write operations with the specified options.

Renames the current file.

Renames the current file. This method also specifies what to do if an existing item in the current file's location has the same name.

Replaces the contents of the file referred to by the specified IStorageFile object with a new data stream. This method lets the app produce the data on-demand by specifying a function to be invoked when the StorageFile that represents the stream is first accessed.

Replaces the contents of the file referred to by the specified IStorageFile object with a new data stream of the specified Uniform Resource Identifier (URI). This method lets the app download the data on-demand when the StorageFile that represents the stream is first accessed.

The data stream is accessed through the StorageFile that is returned and the data is downloaded on-demand when the StorageFile is first accessed.

Replaces the IStorageFile object that represents the specified file with a new StorageFile that provides a stream of the specified Uniform Resource Identifier (URI).

Properties

  • Attributes
    Attributes
    Attributes
    Attributes

    Gets the attributes of a file.

    public FileAttributes Attributes { get; }public FileAttributes Attributes { get; }Public ReadOnly Property Attributes As FileAttributes

    Property Value

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

  • DateCreated
    DateCreated
    DateCreated
    DateCreated

    Gets the date and time when the current file was created.

    public DateTime DateCreated { get; }public DateTime DateCreated { get; }Public ReadOnly Property DateCreated As DateTime

    Property Value

    Remarks

    If the date property isn't set, this value defaults to 0 which can be translated into misleading dates in different programming languages. In JavaScript, for example, 0 translates to December 16, 1600. You should always check that this property is a real value and not 0.

  • DisplayName
    DisplayName
    DisplayName
    DisplayName

    Gets a user-friendly name for the file.

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

    Property Value

    • string
      string
      string
      string

      The user-friendly name for the file.

  • DisplayType
    DisplayType
    DisplayType
    DisplayType

    Gets a user-friendly description of the type of the file.

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

    Property Value

    • string
      string
      string
      string

      The user-friendly description of the type of the file.

    Remarks

    For example, an image file might have a user-friendly type of "JPG File".

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

    Remarks

    For example, an image file might have the ".jpg" file type.

  • FolderRelativeId
    FolderRelativeId
    FolderRelativeId
    FolderRelativeId

    Gets an identifier for the file. This ID is unique for the query result or StorageFolder that contains the file and can be used to distinguish between items that have the same name.

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

    Property Value

    • string
      string
      string
      string

      The identifier for the file.

    Remarks

    You create a query result object when you create a query using one of the methods on a StorageFolder object. Depending on the method you call, your query result object could be a StorageFileQueryResult, a StorageFolderQueryResult, or a StorageItemQueryResult object.

  • IsAvailable
    IsAvailable
    IsAvailable
    IsAvailable

    Indicates if the file is local, is cached locally, or can be downloaded.

    public bool IsAvailable { get; }public bool IsAvailable { get; }Public ReadOnly Property IsAvailable As bool

    Property Value

    • bool
      bool
      bool
      bool

      True if the file is local, is cached locally, or can be downloaded. Otherwise, false.

  • Name
    Name
    Name
    Name

    Gets the name of the file including the file name extension.

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

    Property Value

    • string
      string
      string
      string

      The name of the file including the file name extension.

  • Path
    Path
    Path
    Path

    Gets the full file-system path of the current file, if the file has a path.

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

    Property Value

    • string
      string
      string
      string

      The full path of the file, if the file has a path in the user's file-system.

    Remarks

    Do not rely on this property to access a file because some files may not have file-system paths. For example if the file is backed by a URI, or was picked using the file picker, the file is not guaranteed to have a file-system path.

  • Properties
    Properties
    Properties
    Properties

    Gets an object that provides access to the content-related properties of the file.

    public StorageItemContentProperties Properties { get; }public StorageItemContentProperties Properties { get; }Public ReadOnly Property Properties As StorageItemContentProperties

    Property Value

    Remarks

    Note

    Properties that are get or set using a property handler that is defined by another app (like Microsoft Word) may not be accessible. Instead, you can try to get these properties using a file query that is backed by the system index. For more information, see QueryOptions.

    For more code samples about accessing properties, see the File access sample.

    Examples

    This example demonstrates how to retrieve content properties or specified properties from a file using Properties.

    try
    {
        StorageFile file = rootPage.sampleFile;
           if (file != null)
           {
            StringBuilder outputText = new StringBuilder();
    
               // Get image properties
                  ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();
                  outputText.AppendLine("Date taken: " + imageProperties.DateTaken);
                  outputText.AppendLine("Rating: " + imageProperties.Rating);
    
                  // Specify more properties to retrieve
            readonly string dateAccessedProperty = "System.DateAccessed";
            readonly string fileOwnerProperty = "System.FileOwner";
                  List<string> propertiesName = new List<string>();
                  propertiesName.Add(dateAccessedProperty);
                  propertiesName.Add(fileOwnerProperty);
    
            // Get the specified properties through StorageFile.Properties
                  IDictionary<string, object> extraProperties = await file.Properties.RetrievePropertiesAsync(propertiesName);
                  var propValue = extraProperties[dateAccessedProperty];
                  if (propValue != null)
                  {
                         outputText.AppendLine("Date accessed: " + propValue);
                  }
                  propValue = extraProperties[fileOwnerProperty];
                  if (propValue != null)
                  {
                         outputText.AppendLine("File owner: " + propValue);
                  }
           }
    }
    // Handle errors with catch blocks
    catch (FileNotFoundException)
    {
        // For example, handle a file not found error
    }
    
    
    var file = SdkSample.sampleFile;
    if (file !== null) {
        var outputDiv = document.getElementById("output");
    
        // Get image properties
        file.properties.getImagePropertiesAsync().then(function (imageProperties) {
            outputDiv.innerHTML += "Date taken: " + imageProperties.dateTaken + "<br />";
            outputDiv.innerHTML += "Rating: " + imageProperties.rating + "<br />";
    
            // Specify more properties to retrieve
            var dateAccessedProperty = "System.DateAccessed";
            var fileOwnerProperty    = "System.FileOwner";
    
            // Get the specified properties through storageFile.properties
            return file.properties.retrievePropertiesAsync([fileOwnerProperty, dateAccessedProperty]);
        }).done(function (extraProperties) {
            var propValue = extraProperties[dateAccessedProperty];
            if (propValue !== null) {
                outputDiv.innerHTML += "Date accessed: " + propValue + "<br />";
            }
            propValue = extraProperties[fileOwnerProperty];
            if (propValue !== null) {
                outputDiv.innerHTML += "File owner: " + propValue;
            }
        },
        // Handle errors with an error function
           function (error) {
               // Handle errors encountered while retrieving properties
        });
    }
    

    After GetImagePropertiesAsync() completes, imageProperties gets a ImageProperties object. Additionally, after RetrievePropertiesAsync(Windows.Foundation.Collections.IIterable{System.String}) completes, extraProperties gets an object that contains the specified properties.

    In the example, file contains a StorageFile that represents the file to retrieve properties for.

  • Provider
    Provider
    Provider
    Provider

    Gets the StorageProvider object that contains info about the service that stores the current file.

    public StorageProvider Provider { get; }public StorageProvider Provider { get; }Public ReadOnly Property Provider As StorageProvider

    Property Value

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 of the file created in the destinationFolder.

    Remarks

    This method uses the FailIfExists value from the CreationCollisionOption enumeration by default. That is, this method raises an exception if a file with the same name already exists in the destination folder. If you want to handle a file name collision in a different way, call the CopyAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption) overloaded method.

    Examples

    The following example copies a file to the specified folder and renames the copy by calling the CopyAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.NameCollisionOption) method. This example explicitly specifies a value for option that replaces the file in the destination folder if a file with the specified name already exists.

    using Windows.Storage;
    using System.Threading.Tasks;
    
    // Get the app's temporary folder.
    StorageFolder tempFolder = ApplicationData.Current.TemporaryFolder;
    
    // Create a sample file in the temporary folder.
    string newFileName = "test.txt";
    StorageFile newFile = await tempFolder.CreateFileAsync(newFileName);
    
    // Get the app's local folder to use as the destination folder.
    StorageFolder localFolder = ApplicationData.Current.LocalFolder;
    
    // Specify a new name for the copied file.
    string renamedFileName = "renamed_test.txt";
    
    // Copy the file to the destination folder and rename it.
    // Replace the existing file if the file already exists.
    StorageFile copiedFile = await newFile.CopyAsync(localFolder, renamedFileName, NameCollisionOption.ReplaceExisting);
    
    // Get the app's temporary folder.
    var ApplicationData = Windows.Storage.ApplicationData;
    var tempFolder = ApplicationData.current.temporaryFolder;
    
    // Create a sample file in the temporary folder.
    var newFileName = "test.txt";
    var newFilePromise = tempFolder.createFileAsync(newFileName);
    var copiedFilePromise = newFilePromise.then(function (newFile) 
    {
        // Get the app's local folder to use as the destination folder.
        var localFolder = ApplicationData.current.localFolder;
    
        // Specify a new name for the copied file.
        var renamedFileName = "renamed_test.txt";
    
        // Copy the file to the destination folder and rename it.
        // Replace the existing file if the file already exists.
        var NameCollisionOption = Windows.Storage.NameCollisionOption;
        return newFile.copyAsync(localFolder, renamedFileName, NameCollisionOption.replaceExisting);
    });
    copiedFilePromise.done(function copySuccess(copiedFile) 
    {
        // File was copied to the destination folder.
    }, function copyFail(failure) 
    {
        // File creation or copy failed.
    });
    
     //Get the app's temporary folder
     StorageFolder^ sourceFolder = ApplicationData::Current->TemporaryFolder;
     StorageFolder^ targetFolder = ApplicationData::Current->LocalFolder;
    
     // Choose source file name and new name for the copied file
     String^ newFileName = "test.txt";
     String^ copyFileName = "renamed_test.txt";
    
     //Create a sample file in the temporary folder
     auto copyFileTask = create_task(sourceFolder->CreateFileAsync(newFileName, Windows::Storage::CreationCollisionOption::ReplaceExisting)).then
      ([targetFolder, copyFileName](StorageFile^ sourceFile) -> task<StorageFile^>
     {
      //Overwrite any exisitng file with the same name 
      auto copyFileTask = sourceFile->CopyAsync(targetFolder,copyFileName,Windows::Storage::NameCollisionOption::ReplaceExisting);
      return create_task(copyFileTask);
     }).then([](StorageFile^ copiedFile){
      //do something with copied file
     });
    
  • 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 and renames the copy.

    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 of the file is created.

    • desiredNewName
      System.String
      System.String
      System.String
      System.String

      The new name for the copy of the file created in the destinationFolder.

    Returns

    • When this method completes, it returns a StorageFile that represents the copy of the file created in the destinationFolder.

  • 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 and renames the copy. This method also specifies what to do if a file with the same name already exists in the destination folder.

    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 of the file created in the destinationFolder.

  • CreateStreamedFileAsync(System.String,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)
    CreateStreamedFileAsync(System.String,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)
    CreateStreamedFileAsync(System.String,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)
    CreateStreamedFileAsync(System.String,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)

    Creates a StorageFile to represent the specified stream of data. This method lets the app produce the data on-demand by specifying a function to be invoked when the StorageFile that represents the stream is first accessed.

    public static IAsyncOperation<StorageFile> CreateStreamedFileAsync(System.String,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)public static IAsyncOperation<StorageFile> CreateStreamedFileAsync(System.String,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)Public Static Function CreateStreamedFileAsync(System.String,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference) As IAsyncOperation( Of StorageFile )

    Parameters

    Returns

    • When this method completes, it returns a StorageFile object that represents the new stream of data.

    Remarks

    Both this method and CreateStreamedFileFromUriAsync(System.String,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference) can be used to create a StorageFile that can be passed to other methods or passed to another app through app contracts.

    These methods let you defer expensive operations to produce the data until that data needed (when it is first accessed). This avoids creating unnecessary delays in user interaction while the data is produced.

  • CreateStreamedFileFromUriAsync(System.String,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)
    CreateStreamedFileFromUriAsync(System.String,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)
    CreateStreamedFileFromUriAsync(System.String,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)
    CreateStreamedFileFromUriAsync(System.String,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)

    Creates a StorageFile to represent a stream of data from the specified Uniform Resource Identifier (URI) resource. This method lets the app download the data on-demand when the StorageFile that represents the stream is first accessed.

    public static IAsyncOperation<StorageFile> CreateStreamedFileFromUriAsync(System.String,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)public static IAsyncOperation<StorageFile> CreateStreamedFileFromUriAsync(System.String,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)Public Static Function CreateStreamedFileFromUriAsync(System.String,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference) As IAsyncOperation( Of StorageFile )

    Parameters

    Returns

    • When this method completes, it returns a StorageFile object that represents the Uniform Resource Identifier (URI) resource.

    Remarks

    This method is nearly equivalent to CreateStreamedFileAsync(System.String,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference), except when using this method, the system provides a StreamedFileDataRequestedHandler on the app's behalf and implements this function to download the specified Uri into the streamed file.

  • DeleteAsync()
    DeleteAsync()
    DeleteAsync()
    DeleteAsync()

    Deletes the current file.

    public IAsyncAction DeleteAsync()public IAsyncAction DeleteAsync()Public Function DeleteAsync() As IAsyncAction

    Returns

    Remarks

    This method uses StorageDeleteOption to determine whether the item is deleted permanently.

    FileNotFoundException is thrown if the file does not exist..

  • DeleteAsync(Windows.Storage.StorageDeleteOption)
    DeleteAsync(Windows.Storage.StorageDeleteOption)
    DeleteAsync(Windows.Storage.StorageDeleteOption)
    DeleteAsync(Windows.Storage.StorageDeleteOption)

    Deletes the current file, optionally deleting the item permanently.

    public IAsyncAction DeleteAsync(Windows.Storage.StorageDeleteOption)public IAsyncAction DeleteAsync(Windows.Storage.StorageDeleteOption)Public Function DeleteAsync(Windows.Storage.StorageDeleteOption) As IAsyncAction

    Parameters

    Returns

  • GetBasicPropertiesAsync()
    GetBasicPropertiesAsync()
    GetBasicPropertiesAsync()
    GetBasicPropertiesAsync()

    Gets the basic properties of the current file.

    public IAsyncOperation<BasicProperties> GetBasicPropertiesAsync()public IAsyncOperation<BasicProperties> GetBasicPropertiesAsync()Public Function GetBasicPropertiesAsync() As IAsyncOperation( Of BasicProperties )

    Returns

    • When this method completes successfully, it returns the basic properties of the current file as a BasicProperties object.

    Remarks

    Examples

    This example shows you how to access basic properties of a file using the GetBasicPropertiesAsync() method.

    storageFile.getBasicPropertiesAsync().then(
        function (basicProperties) {
            var size  = basicProperties.size;
        }
    );
    

    You must have a StorageFile object (storageFile in the example) that represents your file in order to use the GetBasicPropertiesAsync() method.

  • GetFileFromApplicationUriAsync(Windows.Foundation.Uri)
    GetFileFromApplicationUriAsync(Windows.Foundation.Uri)
    GetFileFromApplicationUriAsync(Windows.Foundation.Uri)
    GetFileFromApplicationUriAsync(Windows.Foundation.Uri)

    Gets a StorageFile object to represent the specified Uniform Resource Identifier (URI) app resource. For examples of sample URIs see How to load file resources.

    public static IAsyncOperation<StorageFile> GetFileFromApplicationUriAsync(Windows.Foundation.Uri)public static IAsyncOperation<StorageFile> GetFileFromApplicationUriAsync(Windows.Foundation.Uri)Public Static Function GetFileFromApplicationUriAsync(Windows.Foundation.Uri) As IAsyncOperation( Of StorageFile )

    Parameters

    Returns

    • When this method completes, it returns a StorageFile object that represents the Uniform Resource Identifier (URI) resource.

    Remarks

    You can use this method to access your app's resources using either "ms-appx://" or "ms-appdata://" Uniform Resource Identifier (URI).

    Examples

    var uri = new Windows.Foundation.Uri("ms-appx:///datafile.xml")
    Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done( /* Your success and error handlers */ );
    
  • GetFileFromPathAsync(System.String)
    GetFileFromPathAsync(System.String)
    GetFileFromPathAsync(System.String)
    GetFileFromPathAsync(System.String)

    Gets a StorageFile object to represent the file at the specified path.

    public static IAsyncOperation<StorageFile> GetFileFromPathAsync(System.String)public static IAsyncOperation<StorageFile> GetFileFromPathAsync(System.String)Public Static Function GetFileFromPathAsync(System.String) As IAsyncOperation( Of StorageFile )

    Parameters

    • path
      System.String
      System.String
      System.String
      System.String

      The path of the file to get a StorageFile to represent.

      If your path uses slashes, make sure you use backslashes (). Forward slashes (/) are not accepted by this method.

    Returns

    • When this method completes, it returns the file as a StorageFile.

  • GetParentAsync()
    GetParentAsync()
    GetParentAsync()
    GetParentAsync()

    Gets the parent folder of the current file.

    public IAsyncOperation<StorageFolder> GetParentAsync()public IAsyncOperation<StorageFolder> GetParentAsync()Public Function GetParentAsync() As IAsyncOperation( Of StorageFolder )

    Returns

    • When this method completes, it returns the parent folder as a StorageFolder.

  • GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)

    Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail.

    public IAsyncOperation<StorageItemThumbnail> GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)public IAsyncOperation<StorageItemThumbnail> GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)Public Function GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode) As IAsyncOperation( Of StorageItemThumbnail )

    Parameters

    Returns

    • When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image or null if there is no thumbnail image associated with the item.

  • GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)

    Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail and the requested size.

    public IAsyncOperation<StorageItemThumbnail> GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)public IAsyncOperation<StorageItemThumbnail> GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)Public Function GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32) As IAsyncOperation( Of StorageItemThumbnail )

    Parameters

    • mode

      The enum value that describes the purpose of the thumbnail and determines how the thumbnail image is adjusted.

      For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.

    • requestedSize
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The requested size, in pixels, of the longest edge of the thumbnail. Windows uses the requestedSize as a guide and tries to scale the thumbnail image without reducing the quality of the image.

      If Windows can't find a thumbnail image that it can scale to meet the requested size, a larger thumbnail might be returned. If no larger thumbnail is available, a thumbnail image that is smaller than the requested size might be returned.

    Returns

    • When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image or null if there is no thumbnail image associated with the item.

  • GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)
    GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)

    Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail, the requested size, and the specified options

    public IAsyncOperation<StorageItemThumbnail> GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)public IAsyncOperation<StorageItemThumbnail> GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)Public Function GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions) As IAsyncOperation( Of StorageItemThumbnail )

    Parameters

    • mode

      The enum value that describes the purpose of the thumbnail and determines how the thumbnail image is adjusted.

      For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.

    • requestedSize
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The requested size, in pixels, of the longest edge of the thumbnail. Windows uses the requestedSize as a guide and tries to scale the thumbnail image without reducing the quality of the image.

      If Windows can't find a thumbnail image that it can scale to meet the requested size, a larger thumbnail might be returned. If no larger thumbnail is available, a thumbnail image that is smaller than the requested size might be returned.

    • options

      The enum value that describes the desired behavior to use to retrieve the thumbnail image. The specified behavior might affect the size and/or quality of the image and how quickly the thumbnail image is retrieved.

    Returns

    • When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image or null if there is no thumbnail image associated with the item.

  • GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)

    Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail.

    public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode)Public Function GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode) As IAsyncOperation( Of StorageItemThumbnail )

    Parameters

    Returns

    • When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image or null if there is no thumbnail image associated with the file.

    Remarks

    For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.

    In Windows Phone Store app, the GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32) method returns the default icon for a music file instead of the expected icon. This happens when you call the GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32) method with a ThumbnailMode value of MusicView.

  • GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)

    Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail and the requested size.

    public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32)Public Function GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32) As IAsyncOperation( Of StorageItemThumbnail )

    Parameters

    • mode

      The enum value that describes the purpose of the thumbnail and determines how the thumbnail image is adjusted.

      For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.

    • requestedSize
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The requested size, in pixels, of the longest edge of the thumbnail. Windows uses the requestedSize as a guide and tries to scale the thumbnail image without reducing the quality of the image.

      If Windows can't find a thumbnail image that it can scale to meet the requested size, a larger thumbnail might be returned. If no larger thumbnail is available, a thumbnail image that is smaller than the requested size might be returned.

    Returns

    • When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image or null if there is no thumbnail image associated with the file.

  • GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)
    GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)

    Retrieves an adjusted thumbnail image for the file, determined by the purpose of the thumbnail, the requested size, and the specified options.

    public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)public IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions)Public Function GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions) As IAsyncOperation( Of StorageItemThumbnail )

    Parameters

    • mode

      The enum value that describes the purpose of the thumbnail and determines how the thumbnail image is adjusted.

      For guidance about choosing the best thumbnail mode, see Guidelines and checklist for thumbnails.

    • requestedSize
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The requested size, in pixels, of the longest edge of the thumbnail. Windows uses the requestedSize as a guide and tries to scale the thumbnail image without reducing the quality of the image.

      If Windows can't find a thumbnail image that it can scale to meet the requested size, a larger thumbnail might be returned. If no larger thumbnail is available, a thumbnail image that is smaller than the requested size might be returned.

    • options

      The enum value that describes the desired behavior to use to retrieve the thumbnail image. The specified behavior might affect the size and/or quality of the image and how quickly the thumbnail image is retrieved.

    Returns

    • When this method completes successfully, it returns a StorageItemThumbnail that represents the thumbnail image or null if there is no thumbnail image associated with the file.

    Remarks

    Examples

    This example shows you how to capture the thumbnail of a file using the GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32,Windows.Storage.FileProperties.ThumbnailOptions) method.

    storageFile.getThumbnailAsync(
        Windows.Storage.FileProperties.ThumbnailMode.musicView,
        100,
        Windows.Storage.FileProperties.ThumbnailOptions.useCurrentScale).then(
            function (storageItemThumbnail) {
                // Add code to process thumbnail
            }
        );
    

    You must have a StorageFile object (storageFile in the example) that represents your file in order to use one of the GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode,System.UInt32) methods.

  • IsEqual(Windows.Storage.IStorageItem)
    IsEqual(Windows.Storage.IStorageItem)
    IsEqual(Windows.Storage.IStorageItem)
    IsEqual(Windows.Storage.IStorageItem)

    Indicates whether the current file is equal to the specified file.

    public bool IsEqual(Windows.Storage.IStorageItem)public bool IsEqual(Windows.Storage.IStorageItem)Public Function IsEqual(Windows.Storage.IStorageItem) As bool

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      Returns true if the current file is equal to the specified file; otherwise false.

    Remarks

    Use the IsEqual(Windows.Storage.IStorageItem) method to determine whether two storage items represent the same file or folder.

    This method compares the Path property of both items to determine if they are the same. If there is no Path (if the item is a library for example), or if the paths do not match the items are compared using IShellItem::Compare.

    This example shows how to compare two storage files for equality.

    function openNewFile() {
        var picker = new Windows.Storage.Pickers.FileOpenPicker;
        picker.fileTypeFilter.replaceAll(["*"]);
        picker.pickSingleFileAsync().then(function (file) {
            var alreadyOpenedFile = null;
            _openFiles.some(function (openFile) {
                if (file.IsEqual(openFile.file)) {
                    alreadyOpenedFile = openFile;
                    return true;
                }
                return false;
            });
    
            if (alreadyOpenedFile != null) {
                alreadyOpenedFile.window.activate();
            } else {
                createNewFileViewerWindow(file);
            }
        });
    }
    
  • IsOfType(Windows.Storage.StorageItemTypes)
    IsOfType(Windows.Storage.StorageItemTypes)
    IsOfType(Windows.Storage.StorageItemTypes)
    IsOfType(Windows.Storage.StorageItemTypes)

    Determines whether the current StorageFile matches the specified StorageItemTypes value.

    public bool IsOfType(Windows.Storage.StorageItemTypes)public bool IsOfType(Windows.Storage.StorageItemTypes)Public Function IsOfType(Windows.Storage.StorageItemTypes) As bool

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      True if the StorageFile matches the specified value; otherwise false.

  • 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 with the specified options over the specified 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

    • When this method completes, it returns an IRandomAccessStream that contains the requested random-access stream.

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

    Opens a random-access stream with the specified options over the specified file.

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

    Parameters

    Returns

    • When this method completes, it returns an IRandomAccessStream that contains the requested random-access stream.

  • OpenReadAsync()
    OpenReadAsync()
    OpenReadAsync()
    OpenReadAsync()

    Opens a random-access stream over the current file for reading file contents.

    public IAsyncOperation<IRandomAccessStreamWithContentType> OpenReadAsync()public IAsyncOperation<IRandomAccessStreamWithContentType> OpenReadAsync()Public Function OpenReadAsync() As IAsyncOperation( Of IRandomAccessStreamWithContentType )

    Returns

  • OpenSequentialReadAsync()
    OpenSequentialReadAsync()
    OpenSequentialReadAsync()
    OpenSequentialReadAsync()

    Opens a sequential-access stream over the current file for reading file contents.

    public IAsyncOperation<IInputStream> OpenSequentialReadAsync()public IAsyncOperation<IInputStream> OpenSequentialReadAsync()Public Function OpenSequentialReadAsync() As IAsyncOperation( Of IInputStream )

    Returns

    • When this method completes, it returns the sequential-access stream (type IInputStream ).

  • OpenTransactedWriteAsync()
    OpenTransactedWriteAsync()
    OpenTransactedWriteAsync()
    OpenTransactedWriteAsync()

    Opens a random-access stream to the file that can be used for transacted-write operations.

    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.

  • OpenTransactedWriteAsync(Windows.Storage.StorageOpenOptions)
    OpenTransactedWriteAsync(Windows.Storage.StorageOpenOptions)
    OpenTransactedWriteAsync(Windows.Storage.StorageOpenOptions)
    OpenTransactedWriteAsync(Windows.Storage.StorageOpenOptions)

    Opens a random-access stream to the file that can be used for transacted-write operations with the specified options.

    public IAsyncOperation<StorageStreamTransaction> OpenTransactedWriteAsync(Windows.Storage.StorageOpenOptions)public IAsyncOperation<StorageStreamTransaction> OpenTransactedWriteAsync(Windows.Storage.StorageOpenOptions)Public Function OpenTransactedWriteAsync(Windows.Storage.StorageOpenOptions) As IAsyncOperation( Of StorageStreamTransaction )

    Parameters

    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(System.String)
    RenameAsync(System.String)
    RenameAsync(System.String)
    RenameAsync(System.String)

    Renames the current file.

    public IAsyncAction RenameAsync(System.String)public IAsyncAction RenameAsync(System.String)Public Function RenameAsync(System.String) As IAsyncAction

    Parameters

    • desiredName
      System.String
      System.String
      System.String
      System.String

      The desired, new name of the current item.

    Returns

    Remarks

    If the name you specify is invalid, this method throws an exception. To handle all the ways the specified name could be invalid, you must catch all four of these exceptions:

    E_INVALIDARG
    E_FAIL
    ERROR_FILENAME_EXCED_RANGE
    ERROR_INVALID_NAME

    If the file is deleted before the rename finishes, this method throws the ERROR_FILE_NOT_FOUND exception. You must also catch and handle this exception when you use this method.

  • RenameAsync(System.String,Windows.Storage.NameCollisionOption)
    RenameAsync(System.String,Windows.Storage.NameCollisionOption)
    RenameAsync(System.String,Windows.Storage.NameCollisionOption)
    RenameAsync(System.String,Windows.Storage.NameCollisionOption)

    Renames the current file. This method also specifies what to do if an existing item in the current file's location has the same name.

    public IAsyncAction RenameAsync(System.String,Windows.Storage.NameCollisionOption)public IAsyncAction RenameAsync(System.String,Windows.Storage.NameCollisionOption)Public Function RenameAsync(System.String,Windows.Storage.NameCollisionOption) As IAsyncAction

    Parameters

    • desiredName
      System.String
      System.String
      System.String
      System.String

      The desired, new name of the current file.

      If there is an existing item in the current file's location that already has the specified desiredName, the specified NameCollisionOption determines how Windows responds to the conflict.

    • option

      The enum value that determines how Windows responds if the desiredName is the same as the name of an existing item in the current file's location.

    Returns

  • ReplaceWithStreamedFileAsync(Windows.Storage.IStorageFile,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)
    ReplaceWithStreamedFileAsync(Windows.Storage.IStorageFile,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)
    ReplaceWithStreamedFileAsync(Windows.Storage.IStorageFile,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)
    ReplaceWithStreamedFileAsync(Windows.Storage.IStorageFile,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)

    Replaces the contents of the file referred to by the specified IStorageFile object with a new data stream. This method lets the app produce the data on-demand by specifying a function to be invoked when the StorageFile that represents the stream is first accessed.

    public static IAsyncOperation<StorageFile> ReplaceWithStreamedFileAsync(Windows.Storage.IStorageFile,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)public static IAsyncOperation<StorageFile> ReplaceWithStreamedFileAsync(Windows.Storage.IStorageFile,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference)Public Static Function ReplaceWithStreamedFileAsync(Windows.Storage.IStorageFile,Windows.Storage.StreamedFileDataRequestedHandler,Windows.Storage.Streams.IRandomAccessStreamReference) As IAsyncOperation( Of StorageFile )

    Parameters

    Returns

    • When this method completes, it returns a StorageFile object that represents the new data stream. Subsequently, this StorageFile object should be used to access file content instead of the file (type IStorageFile ) that was specified to be replace.

    Remarks

    This method lets you defer expensive operations to produce the data until that data needed (when it is first accessed). This avoids creating unnecessary delays in user interaction while the data is produced.

  • ReplaceWithStreamedFileFromUriAsync(Windows.Storage.IStorageFile,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)
    ReplaceWithStreamedFileFromUriAsync(Windows.Storage.IStorageFile,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)
    ReplaceWithStreamedFileFromUriAsync(Windows.Storage.IStorageFile,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)
    ReplaceWithStreamedFileFromUriAsync(Windows.Storage.IStorageFile,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)

    Replaces the contents of the file referred to by the specified IStorageFile object with a new data stream of the specified Uniform Resource Identifier (URI). This method lets the app download the data on-demand when the StorageFile that represents the stream is first accessed.

    The data stream is accessed through the StorageFile that is returned and the data is downloaded on-demand when the StorageFile is first accessed.

    Replaces the IStorageFile object that represents the specified file with a new StorageFile that provides a stream of the specified Uniform Resource Identifier (URI).

    public static IAsyncOperation<StorageFile> ReplaceWithStreamedFileFromUriAsync(Windows.Storage.IStorageFile,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)public static IAsyncOperation<StorageFile> ReplaceWithStreamedFileFromUriAsync(Windows.Storage.IStorageFile,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference)Public Static Function ReplaceWithStreamedFileFromUriAsync(Windows.Storage.IStorageFile,Windows.Foundation.Uri,Windows.Storage.Streams.IRandomAccessStreamReference) As IAsyncOperation( Of StorageFile )

    Parameters

    Returns

    • When this method completes, it returns a StorageFile object that represents the streamed file. Subsequently, this StorageFile object should be used to access file content instead of the file (type IStorageFile ) that was specified to be replace.

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.MuseAttribute
Windows.Foundation.Metadata.StaticAttribute

Details

Assembly

Windows.Storage.dll