【问题标题】:windows phone 8.1 RT error with files creationwindows phone 8.1 RT 错误与文件创建
【发布时间】:2017-08-21 17:18:27
【问题描述】:

根据本教程: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh758325.aspx?f=255&MSPPError=-2147217396

我写了以下函数:

private async void WriteToFile()
{
   StorageFolder folder =
   Windows.Storage.ApplicationData.Current.LocalFolder;
   StorageFile sampleFile =
   await folder.CreateFileAsync("sample.txt", CreationCollisionOption.ReplaceExisting);
}

但是,如果我运行它,我会看到以下错误:

Exception thrown: 'System.ArgumentException' in mscorlib.ni.dll
Use of undefined keyword value 1 for event TaskScheduled.

为什么?我该如何解决这个问题?

【问题讨论】:

    标签: c# windows-phone


    【解决方案1】:

    它给出的错误就像 “附加信息:对事件 TaskScheduled 使用未定义的关键字值 1” 所以可能 sample.txt 不能定义为它的 undefined 关键字。

    将文件名改成其他名称或“sample1.txt”即可。

    private async void WriteToFile()
    {
       StorageFolder folder =
       Windows.Storage.ApplicationData.Current.LocalFolder;
       StorageFile sampleFile =
       await folder.CreateFileAsync("sample1.txt", CreationCollisionOption.ReplaceExisting);
    }
    

    【讨论】:

    • 是的,已经检查过了,它可以使用除“sample.txt”以外的任何名称
    • 难以置信,它的工作。问题是名字。以前从没见过类似依赖的名字。你是个巫师!编辑:对不起,我没有声望给你投票。
    • 但是......如果我从 onnavigateto 调用它,它会完美运行......如果我从一个按钮调用它就不起作用。为什么?感谢! (随便哪,帖子都解决了)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-04
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多