Expand Minimize

StorageFile.ReplaceWithStreamedFileAsync | replaceWithStreamedFileAsync method

Applies to Windows only

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 Shared Function ReplaceWithStreamedFileAsync(
  fileToReplace As IStorageFile,  
  dataRequested As StreamedFileDataRequestedHandler,  
  thumbnail As IRandomAccessStreamReference 
) As IAsyncOperation(Of StorageFile)



Type: IStorageFile

The file (type IStorageFile) that the new data stream should be written to.


Type: StreamedFileDataRequestedHandler

The function that should be invoked when the StorageFile that is returned is first accessed. This function should produce the data stream represented by the returned StorageFile and lets the app produce data on-demand instead of writing the contents of the file at creation time.


Type: IRandomAccessStreamReference

The thumbnail image for the StorageFile to create.

For a high-quality thumbnail, one edge of this thumbnail should be at least 1024 pixels.

Return value

Type: IAsyncOperation<StorageFile>

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.


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.


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported


Windows::Storage [C++]



See also




© 2015 Microsoft