none
Unable to use Windows.Storage.FileIO.WriteTextAsync

    Question

  • I am building a C# metro app using VS2011 express for Windows Developer Preview.

    The app intends to write some data in a text file in the temp location through an "async" function that has the following code-

    Windows.Storage.StorageFile file = await Windows.Storage.ApplicationData.Curent.TemporaryFolder.CreateFileAsync("a.txt");

                //await Windows.Storage.FileIO.WriteTextAsync(file, "\n try n try again");

    The line #2 has to be commented as it fails to compile with the following error - 

    "The type or namespace name 'FileIO' does not exist in the namespace 'Windows.Storage' (are you missing an assembly reference?). "

    I fail to understand this behaviour as "FileIO" namespace is everywhere mentioned to be a part of "Windows.Storage". Can somebody help please?

    Friday, March 23, 2012 11:41 AM

Answers

All replies

  • Why Developer Preview(DP)?
    DP does not have the Windows.Storage.FileIO class.

    If you want to still use DP, please check about the Windows.Storage.Streams.DataWriter class.
    However, the official documents are already deleted. Please search blogs etc.
    For example: http://www.sharpgis.net/post/2012/01/12/Reading-and-Writing-text-files-in-Windows-8-Metro.aspx



    biac [ http://bluewatersoft.cocolog-nifty.com/ ]


    Friday, March 23, 2012 1:32 PM
  • Biac is correct - please upgrade to Consumer Preview to use the latest APIs.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator

    Friday, March 23, 2012 7:54 PM
  • Thanks a lot for the clarification!

    Does this mean that from a developer's perspective, the Win8 "consumer preview" is an upgraded version of the "developer preview" as it has more functionality?

    Monday, March 26, 2012 4:32 AM
  • Yes, it's an upgraded version of Windows 8.  CP contains bug fixes and new functionality that DP did not have.   The same will be true of the next version as well.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator

    Monday, March 26, 2012 1:47 PM