[英]StreamReader doesn't take string?
我正在嘗試使用StreamReader讀取文件,但是使用path
出現錯誤
參數1:無法從“字符串”轉換為System.IO.Stream
即使從文檔中可以明顯看出,您也應該可以使用字符串。
我在這里想念什么?
public MyClass Load(String path)
{
try
{
// exception in this line, `path` is underlined with red
using (StreamReader reader = new StreamReader(path))
{
String line = reader.ReadLine();
// ... etc
我無法告訴您答案是否正確,但UWP的正確語法如下:
using (var sr = new StreamReader(new FileStream(filenamestring, FileMode.Open)))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.