Skip to main content
 首页 » 编程设计

c#之无法从字符串创建 StreamReader 类

2024年02月06日21itcoder

我无法从字符串创建 StreamReader 对象。这是代码:

 StreamReader reader = new StreamReader(filePath); 

这是我得到的确切错误:

The best overloaded match for 'StreamReader'(StreamReader(Stream)) has some invalid arguments

它只是没有任何意义,我查看了微软网站和其他任何地方(包括本网站)上的文件 IO,它只是没有找到 StreamReader 的字符串构造函数。我使用 VS 2013 Professional 作为我的 IDE,我还使用了 monogame(XAML) 模板。

请您参考如下方法:

There is a StreamReader(string) constructor ,但不是在所有配置文件中 - 注意过载是如何 missing the icons适用于 PCL 和 Windows 应用商店应用程序。所以要么;

  1. 构造函数重载受限于(不存在于)目标配置文件中,或者

  2. 范围内有不同的 StreamReader。

鉴于错误消息表明它正在尝试最佳匹配 StreamReader(Stream),可能的原因是 #1,因为所述消耗流的构造函数可用在 Windows 应用商店应用程序中。