2015-05-25 85 views
0

在按照本教程: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh758325.aspx?f=255&MSPPError=-2147217396的Windows Phone 8.1 RT差错处理文件创建

我写了下面的功能:

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. 

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

回答

0

它给人错误,如 “附加信息:事件未定义的关键字值1的使用TaskScheduled” 所以可SAMPLE.TXT能不能定义为未定义的关键字。

将文件名更改为其他名称或“sample1.txt”,它将起作用。

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

将文件名更改为其他名称或“sample1.txt”,它将起作用。 什么? – Archimede

+0

是的,检查它,它的工作与“sample.txt”以外的任何名称 – Jigs257

+0

令人难以置信,这是工作。问题在于名称。从名字中看不到类似的依赖关系。你是一个巫师! 编辑:对不起,我没有一些声望投票给你。 – Archimede

相关问题