locked
How to use CreateStreamedFileAsync? RRS feed

  • Question

  • I need a sample on using CrateStreamedFileAsync in metro style app or some code template for using CreateStreamedFileAsync in metro style app. The sample code can be in either c# or c++ winRT.
    Friday, July 20, 2012 4:37 AM

Answers

  • You can request sasmples here:
    http://code.msdn.microsoft.com/windowsapps/site/requests

    You write a method which creates the content of your file, then call CreateStreamedFileAsync, passing in that method as a parameter.  CreateStreamedFileAsync calls your method to get the data to write to the StorageFile, so it works on-demand rather than having to create the information before hand.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    • Proposed as answer by Can Bilgin Saturday, July 21, 2012 7:50 AM
    • Marked as answer by Jesse Jiang Friday, August 10, 2012 6:57 AM
    Friday, July 20, 2012 2:17 PM
    Moderator
  • IAsyncOperation<StorageFile> CreateStreamedFileAsync(destfilename, dataRequested, OutputImageFile);

    this line has to change to:

    var storageFile = await StorageFile.CreateStreamedFileAsync(destfilename, dataRequested, OutputImageFile);

    this is of course if you want to wait for the resulting storage file.


    Can Bilgin
    Blog CompuSight

    • Marked as answer by Jesse Jiang Friday, August 10, 2012 6:57 AM
    Monday, July 23, 2012 1:39 PM

All replies

  • You can request sasmples here:
    http://code.msdn.microsoft.com/windowsapps/site/requests

    You write a method which creates the content of your file, then call CreateStreamedFileAsync, passing in that method as a parameter.  CreateStreamedFileAsync calls your method to get the data to write to the StorageFile, so it works on-demand rather than having to create the information before hand.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    • Proposed as answer by Can Bilgin Saturday, July 21, 2012 7:50 AM
    • Marked as answer by Jesse Jiang Friday, August 10, 2012 6:57 AM
    Friday, July 20, 2012 2:17 PM
    Moderator
  • I am coding like this

    StreamedFileDataRequestedHandler

    dataRequested = image.Convert(InFile, Id, InputImageFile, OutputImageFile);

                 

    IAsyncOperation<StorageFile> CreateStreamedFileAsync(destfilename, dataRequested, OutputImageFile);

    Getting compiler error: Error 1 Expected ; or = (cannot specify constructor arguments in declaration) at CreateStreamedFileAsync. Please send some c# sample on how to use CreateStreamedFileAsync.

    Monday, July 23, 2012 4:51 AM
  • IAsyncOperation<StorageFile> CreateStreamedFileAsync(destfilename, dataRequested, OutputImageFile);

    this line has to change to:

    var storageFile = await StorageFile.CreateStreamedFileAsync(destfilename, dataRequested, OutputImageFile);

    this is of course if you want to wait for the resulting storage file.


    Can Bilgin
    Blog CompuSight

    • Marked as answer by Jesse Jiang Friday, August 10, 2012 6:57 AM
    Monday, July 23, 2012 1:39 PM
  • Here's a complete example of how to use this method:

    http://socialeboladev.wordpress.com/2013/03/15/how-to-use-createstreamedfileasync/


    Blog: http://socialebola.wordpress.com

    Friday, March 15, 2013 11:24 AM