1

次のコードを使用してファイルに書き込もうとしています。

StorageFolder ^localFolder = ApplicationData::Current->LocalFolder;
concurrency::task<StorageFile^> fileOperation = localFolder->CreateFileAsync("data.txt", CreationCollisionOption::ReplaceExisting);
fileOperation.then([this](StorageFile^ sampleFile)
{
    ::Globalization::DateTimeFormatting::DateTimeFormatter("longtime");
    Platform::String ^str; // other str stuff here

    return FileIO::WriteTextAsync(sampleFile, str);
}).then([this](concurrency::task<void> previousOperation) {
    try {
        previousOperation.get();
    } catch (Platform::Exception^) {
    }
});

「時々開発者」のおかげでエラーを修正しました

ここからコードを取得しました:http: //msdn.microsoft.com/en-us/library/windows/apps/xaml/hh700361.aspx

4

1 に答える 1

1

この行を置き換えるだけです:

concurrency::task<StorageFile^> fileOperation = localFolder->CreateFileAsync("data.txt",
    CreationCollisionOption::ReplaceExisting);

この行で:

concurrency::task<StorageFile^> fileOperation(localFolder->CreateFileAsync("data.txt",
    CreationCollisionOption::ReplaceExisting));
于 2012-12-16T03:11:53.477 に答える