2016-11-19 56 views
2

我正在將.NET 4.6.1控制檯應用程序移植到.NET Core。沒有StreamReader構造函數接受字符串

我安裝了NETStandard.Library 1.6,它不讓我將文件路徑字符串傳遞給StreamReader構造函數。查看定義證實,它的不可用:

enter image description here

哪裏是它到哪裏去了?

+0

更改您的.NET應用程序,首先打開文件流,然後將其傳遞給StreamReader? – Evk

+0

謝謝 - 我已經這樣做了,但我也試圖瞭解我的配置/依賴關係是否設置錯誤,或者如果這是有意的。 – user888734

+0

沒有你的配置是好的。它不在Core中,你可以在這裏看到:https://docs.microsoft.com/en-us/dotnet/core/api/system.io.streamreader – CodingYoshi

回答

3

這是正確的。 .Net Core 1.0/.Net Standard 1.x重構了基本庫,因此基本流類型(如StreamReader)位於the System.IO packageFileStream位於the System.IO.FileSystem package。由於您正在尋找的構造函數需要StreamReader才能取決於FileStream,因此將其刪除。

請注意,對於即將推出的.Net Core 2.0/.Net Standard 2.0,這個重構的很大一部分是相反的,所以you will be able to use this constructor on .Net Core in the future

相關問題