没有接受字符串的 StreamReader 构造函数 [英] No StreamReader constructor accepting a string

查看:26
本文介绍了没有接受字符串的 StreamReader 构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 .NET 4.6.1 控制台应用程序移植到 .NET Core.

I'm porting a .NET 4.6.1 console app to .NET Core.

我安装了 NETStandard.Library 1.6,但它不允许我将文件路径字符串传递给 StreamReader 构造函数.查看定义确认它不可用:

I have NETStandard.Library 1.6 installed, and it's not letting me pass a file path string into a StreamReader constructor. Viewing the definition confirms that it's not available:

哪里去了?

推荐答案

这是正确的..Net Core 1.0/.Net Standard 1.x 重构了基础库,以便像 StreamReader 这样的基本流类型在 System.IOFileStream 位于 System.IO.FileSystem.由于您要查找的构造函数需要 StreamReader 依赖于 FileStream,因此已将其删除.

This is correct. .Net Core 1.0/.Net Standard 1.x refactored the base libraries, so that basic stream types like StreamReader are in the System.IO package and FileStream is in the System.IO.FileSystem package. Since the constructor you're looking for would require StreamReader to depend on FileStream, it was removed.

请注意,对于即将推出的 .Net Core 2.0/.Net Standard 2.0,此重构的很大一部分被颠倒了,因此 您将来可以在 .Net Core 上使用此构造函数.

Note that a large part of this refactoring was reversed for the upcoming .Net Core 2.0/.Net Standard 2.0, so you will be able to use this constructor on .Net Core in the future.

这篇关于没有接受字符串的 StreamReader 构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆