C# .net core StreamReader读文件流改为FileStream

见Stackoverflow的提问. 原先在NET Framework下,StreamReader中提供重载的方式直接读取文件流.但是在.net core中已经取消了该重载方法,为了移植到.net core只需添加一行代码即可. string fileName = “xxxx”; … //原来只用这一句 //StreamReader mysr = new StreamReader(fileName, Encoding.UTF8); //现在需要添加FileStream. var sw = new FileStream(fileName, FileMode.Open); StreamReader mysr = new StreamReader(sw); …

Read More

C# .net core 使用NameValueCollection类

微软更新了.net core的一些引用规则,详见GitHub的Issue. 其中包含了原来的NameSpace: – System.Collections.NonGeneric – System.Threading.Overlapped – System.Collections.Specialized – System.Xml.XmlDocument 因此原来只需using 引入的,而现在需要变成安装依赖包的方式了。 VS2017打开程序包管理器控制台,安装Install-Package System.Collections.Specialized即可安装到项目文件.csproj中,使用NameValueCollection便不会提示错误。

Read More