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

查看:106
本文介绍了没有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重构了基础库,因此 = https://www.nuget .org / packages / System.IO / 4.1.0 rel = nofollow noreferrer> System.IO FileStream 位于 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天全站免登陆