本文介绍了'System.IO.Stream'不包含'CopyTo'的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我在C#控制台应用程序中收到错误



Hi I am getting the error in my C# Console application

'System.IO.Stream' does not contain a definition for 'CopyTo' and no extension method 'CopyTo' accepting a first argument of type 'System.IO.Stream' could be found (are you missing a using directive or an assembly reference?)





这是我的代码



This is my code

HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
using (var stream = File.Create(fileName))
{
    response.GetResponseStream().CopyTo(stream);
}





请求帮助。在此先感谢



Pleas help. Thanks in advance

推荐答案


引用:

如果你必须以.NET2为目标怎么办?

将项目更改为.NET4只是作弊

And what if you have to target .NET2?
Changing the project to .NET4 is just cheating

...

[来自Sam Beauvois的例子给出了针对框架的例子< .NET 4.0

...
This blog[^] from Sam Beauvois gives examples that will target frameworks < .NET 4.0



这篇关于'System.IO.Stream'不包含'CopyTo'的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-15 00:56