C# StreamReader没有';你不拿绳子吗?

C# StreamReader没有';你不拿绳子吗?,c#,uwp,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时出错

参数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)))

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

using (var sr = new StreamReader(new FileStream(filenamestring, FileMode.Open)))

@TimSchmelter通过edit.show给我们看你的“路径”,为什么这很重要?这是作为论点通过的。函数声明不知道或不依赖于确切知道路径。根据:此示例中使用的构造函数[使用字符串]不支持在Windows应用商店应用程序中使用。此外,如果您在版本信息部分查找,它会特别提到通用Windows平台(在使用字符串的函数中没有提到这一点)@TimSchmelter通过edit.show us ur'path'标记了它为什么重要?它是作为参数传递的。函数声明不知道或依赖于确切知道路径。根据:构造函数[使用字符串]此示例中使用的不支持在Windows应用商店应用程序中使用。此外,如果您在版本信息部分查找,它会特别提到通用Windows平台(在使用字符串的版本中未提及)