locked
Access text and Xml files in Metro Style App

    Question

  • I am creating an app, which show tiles at startup in win8. In which tiles are updated by accessing files present in my system. I use background task to update tiles every 15 minutes. My code is in C++. But i am not able to read the content of the file..

    void Class1::Run(IBackgroundTaskInstance^ taskInstance)
    {
        BackgroundTaskDeferral^ deferral = taskInstance->GetDeferral();
        TileUpdateManager::CreateTileUpdaterForApplication()->Clear();
        TileUpdateManager::CreateTileUpdaterForApplication()->EnableNotificationQueue(true);
        Notifications();
        deferral->Complete();

    }

    void Taskback1::Notifications()

    {

    concurrency::task<StorageFile^> getFileOperation( KnownFolders::DocumentsLibrary->GetFileAsync("Tiles1.xml"));

    getFileOperation.then([this](StorageFile^ file)
        {
            return FileIO::ReadTextAsync(file);
        }).then([this](concurrency::task<String^> previousOperation) {
            String^ timestamp;
     
         try {
             // Data is contained in timestamp
                timestamp = previousOperation.get();

              
             } catch (...) {
             // Timestamp not found
         }
       });

    }

    The same code for reading file is works fine in MainPage.xaml.cpp but not in my BackgroundTask file Taskback1.cpp.

    Are there some other functions to access files from the system for BackgroundTask file..

    I also used some other methods but failed.

    Friday, December 21, 2012 6:02 AM

All replies