No StreamReader constructor accepting a string

安稳与你 提交于 2019-12-02 05:28:06

问题


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

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:

Where's it gone?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/40697200/no-streamreader-constructor-accepting-a-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!