Metro app,read text file content in to my buffer RRS feed

  • Question

  • Hi,

       How to read each character from a text file, or read data and put into my char buffer in metro app, I am writing in c++;

    Here my code:

    task<StorageFile^>(KnownFolders::DocumentsLibrary->GetFileAsync("mytext.txt")).then([this](task<StorageFile^> getFileTask)


       {  _sampleFile = getFileTask.get();



    if (_sampleFile != nullptr){

            task<String^>(FileIO::ReadTextAsync(_sampleFile)).then([this](String^ fileContent)


               Scenario2Output_textblock->Text = fileContent;



    actually am able to read data in fileContent,but I want to read each character. Can any one help me? 


    Anil Kumar

    • Edited by anili147 Friday, May 11, 2012 10:48 AM
    Friday, May 11, 2012 10:42 AM


  • Hi Anil,

    You can read the string in and then examine the characters in the string.

    If you don't want to do that then look at the File Access sample Scenario 3 for an example of how to hook up a DataReader. You can then read smaller chunks or individual code points with dataReader->ReadString(numCodePoints).


    • Marked as answer by Jesse Jiang Thursday, May 24, 2012 6:59 AM
    Friday, May 11, 2012 8:26 PM