2015-05-25 82 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

相關問題