.net core(dnx core 5.0)是否支持文件流 [英] Does .net core (dnx core 5.0) support filestream

查看:126
本文介绍了.net core(dnx core 5.0)是否支持文件流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用.NET Core的RC1,我在脑海中调查了最棘手的问题!

我可以用.NET Core打开一个该死的FileStream到磁盘上的文件吗?

(而且我的意思是任何地方,比如C:\ temp\a.txt而不只是$ user \ AppData !!!)



所以我打开了visual studio 2015,点击了新项目>网络>控制台应用程序包(是web是本机应用程序的位置!!)



然后我输入new FileStream并查看有用的intellisense建议。 />


这就是我困惑的地方....



new FileStream(....)是:

- 适用于DNX 4.5.1

- 不适用于DNX Core 5.0



当我尝试编译

With the RC1 of .NET Core I went to investigate the most burning question in the back of my mind!
Can I open a damn FileStream to a file on the disk with .NET Core?
(And by that I mean anywhere, like "C:\temp\a.txt" and not just in $user\AppData !!!)

So I opened visual studio 2015, clicked new project > web > Console Application package (yes "web" is where the native app is!!)

then I typed "new FileStream" and looked at the helpful intellisense advice.

And it's where I got confused....

"new FileStream(....)" is:
- available for "DNX 4.5.1"
- NOT available for "DNX Core 5.0"

When I tried to compile

using (var s = new FileStream(@"c:\temp\a.txt", FileMode.Create))
using (var sw = new StreamWriter(s))
    sw.WriteLine("it worked!");



我得到了


I got

Program.cs(13,32,13,42): DNX Core 5.0 error CS0246: The type or namespace name 'FileStream' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(13,61,13,69): DNX Core 5.0 error CS0103: The name 'FileMode' does not exist in the current context



我是使用系统.IO; 这是.NET Core的问题....



这意味着什么?!



我尝试过:



创建了一个新的.NET Core Web应用程序看了intellisense信息


And YES I am using System.IO; it's an "issue" with ".NET Core"....

what does that means?!

What I have tried:

created a new .NET Core web app and looked at intellisense information

推荐答案

user\AppData !!!)



所以我开了视觉工作室2015年,点击新项目>网络>控制台应用程序包(是web是本机应用程序的位置!!)



然后我输入new FileStream并查看有用的intellisense建议。 />


这就是我困惑的地方....



new FileStream(....)是:

- 适用于DNX 4.5.1

- 不适用于DNX Core 5.0



当我尝试编译

user\AppData !!!)

So I opened visual studio 2015, clicked new project > web > Console Application package (yes "web" is where the native app is!!)

then I typed "new FileStream" and looked at the helpful intellisense advice.

And it's where I got confused....

"new FileStream(....)" is:
- available for "DNX 4.5.1"
- NOT available for "DNX Core 5.0"

When I tried to compile
using (var s = new FileStream(@"c:\temp\a.txt", FileMode.Create))
using (var sw = new StreamWriter(s))
    sw.WriteLine("it worked!");



我得到了


I got

Program.cs(13,32,13,42): DNX Core 5.0 error CS0246: The type or namespace name 'FileStream' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(13,61,13,69): DNX Core 5.0 error CS0103: The name 'FileMode' does not exist in the current context



我是使用系统.IO; 这是.NET Core的问题....



这意味着什么?!



我尝试过:



创建了一个新的.NET Core Web应用程序看了intellisense信息


And YES I am using System.IO; it's an "issue" with ".NET Core"....

what does that means?!

What I have tried:

created a new .NET Core web app and looked at intellisense information


我发现了这个:。NET Core和FileStream [ ^ ]



似乎你只能获得基础知识并且必须加载额外的nuget包。
I found this : .NET Core and FileStream[^]

Seems you only get the basics and have to load nuget packages for the extras.


这篇关于.net core(dnx core 5.0)是否支持文件流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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