C#无法从字符串转换为System.IO.Stream
我写了这篇文章,得到了错误“参数1:无法从'string'转换为'System.IO.Stream'。 我在一个控制台应用程序中使用了完全相同的代码,它工作得很好,但将其放入Windows通用应用程序会出现此错误。您尝试过吗C#无法从字符串转换为System.IO.Stream,c#,windows,file,io,stream,C#,Windows,File,Io,Stream,我写了这篇文章,得到了错误“参数1:无法从'string'转换为'System.IO.Stream'。 我在一个控制台应用程序中使用了完全相同的代码,它工作得很好,但将其放入Windows通用应用程序会出现此错误。您尝试过吗 System.IO.StreamReader file = new System.IO.StreamReader("saveData.txt"); 看起来Windows通用应用程序读取文件的功能有所不同: MemoryStream memoryStream= new Me
System.IO.StreamReader file = new System.IO.StreamReader("saveData.txt");
看起来Windows通用应用程序读取文件的功能有所不同:
MemoryStream memoryStream= new MemoryStream(Encoding.UTF8.GetBytes("saveData.txt"));
资料来源:
var file = await ApplicationData.Current.LocalFolder.GetFileAsync("data.txt");
var lines = await FileIO.ReadLinesAsync(file);