我創建了一個windows rt應用程序,其中包含超過1000個.txt文件,我從中獲取其內容。Windows RT:從項目文件夾中讀取文本文件
這些文本文件是我的項目的一部分,但我無法用代碼讀取它們。
這是我的代碼
static async Task ReadFile(string filePath, List<string> list)
{
try
{
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///" + filePath));
var readThis = await FileIO.ReadLinesAsync(file);
foreach (var line in readThis)
{
list.Add(line);
}
}
catch (FileNotFoundException)
{
}
}
其中,filepath是:「TXT /數據/ 14b.txt
當執行代碼清單中填充數據,但應用程序崩潰,我送。在此行app.gics
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
任何想法的?
查看調試器中'e'變量的內容,它給出拋出異常的上下文。它說什麼? – Mic 2013-04-06 18:30:18
[System.ArgumentException] = {「值不在預期範圍內。」} – allocator 2013-04-06 18:31:38
拋出的線是什麼?你確定它位於該代碼中嗎?在那裏放置一個斷點,看看會發生什麼。 – Mic 2013-04-06 18:37:43