2017-03-24 233 views
0
System.IO.StreamReader file = new System.IO.StreamReader("saveData.txt"); 

我寫這個,我得到錯誤「參數1:無法從‘串’到‘System.IO.Stream’轉換 我已經使用此完全相同的代碼在控制檯應用程序,它工作得很好,但把這個變成一個Windows通用應用程序給出了這樣的錯誤。C#無法從字符串轉換成的System.IO.Stream

回答

0

你有沒有試過這種?

MemoryStream memoryStream= new MemoryStream(Encoding.UTF8.GetBytes("saveData.txt")); 
0

它看起來像Windows的通用應用程序閱讀文件功能不同:

var file = await ApplicationData.Current.LocalFolder.GetFileAsync("data.txt"); 
var lines = await FileIO.ReadLinesAsync(file); 

來源:how to read a text file in windows universal app

相關問題