StreamReader 不接受字符串?

lte*_*e__ 1 c# uwp

我正在尝试使用 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
Run Code Online (Sandbox Code Playgroud)

小智 5

我不知道你是否得到了答案,但 UWP 的正确语法如下:

using (var sr = new StreamReader(new FileStream(filenamestring, FileMode.Open)))
Run Code Online (Sandbox Code Playgroud)