{"id":4092,"date":"2017-06-23T15:45:40","date_gmt":"2017-06-23T20:45:40","guid":{"rendered":"http:\/\/neosmart.net\/blog\/?p=4092"},"modified":"2019-06-08T20:58:48","modified_gmt":"2019-06-09T01:58:48","slug":"stuck-on-net-2-0-3-5-copy-streams-easily-with-this-nuget-extension","status":"publish","type":"post","link":"https:\/\/neosmart.net\/blog\/stuck-on-net-2-0-3-5-copy-streams-easily-with-this-nuget-extension\/","title":{"rendered":"Stuck on .NET 2.0 &#8211; 3.5? Copy streams easily with this NuGet extension!"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-4132 colorbox-4092\" src=\"https:\/\/neosmart.net\/blog\/wp-content\/uploads\/stream.copyto-150x150.png\" alt=\"\" width=\"122\" height=\"121\" srcset=\"https:\/\/neosmart.net\/blog\/wp-content\/uploads\/stream.copyto-150x150.png 150w, https:\/\/neosmart.net\/blog\/wp-content\/uploads\/stream.copyto-300x300.png 300w, https:\/\/neosmart.net\/blog\/wp-content\/uploads\/stream.copyto.png 512w\" sizes=\"auto, (max-width: 122px) 100vw, 122px\" \/>If you&#8217;re still stuck on .NET 2.0, 3.0, or 3.5 for any reason and don&#8217;t have access to the <code>.CopyTo<\/code>\u00a0method for <code>System.IO.Stream<\/code>\u00a0objects, the <code>Stream.CopyTo<\/code>\u00a0extension method, available as a small NuGet package will make manually allocating buffers and other boilerplate associated with copying a buffer from one stream to another a thing of the past.<\/p>\n<p><!--more--><\/p>\n<p><code>Stream.CopyTo<\/code>\u00a0is as simple as a NuGet package could be, but it let&#8217;s you use <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/system.io.stream.copyto(v=vs.110).aspx\" rel=\"follow\">.NET 4.0&#8217;s <code>Stream.CopyTo<\/code> method<\/a>\u00a0on earlier versions of the framework. It too resides in the <code>System.IO<\/code>\u00a0namespace and provides the same functions (and overrides) as the official .NET 4.0+ version of its namesake, meaning it&#8217;s a drop-in replacement perfect for publishing multi-targeted code, etc. that &#8220;just works&#8221; on all versions of the .NET Framework.<\/p>\n<p>As with all our other NuGet publications, <code>Stream.CopyTo<\/code>\u00a0is fully open-source and <a href=\"https:\/\/github.com\/neosmart\/Stream.CopyTo\" rel=\"nofollow\">published on GitHub<\/a> under the terms of the MIT license. To make life easier, <a href=\"https:\/\/www.nuget.org\/packages\/Stream.CopyTo\/\" rel=\"follow\">it&#8217;s also available on NuGet<\/a>, making it a single Visual Studio package manager (console) install away.<\/p>\n<p class=\"save\">Download: <a href=\"https:\/\/www.nuget.org\/packages\/Stream.CopyTo\/\" rel=\"follow\">Stream.CopyTo<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re still stuck on .NET 2.0, 3.0, or 3.5 for any reason and don&#8217;t have access to the .CopyTo\u00a0method for System.IO.Stream\u00a0objects, the Stream.CopyTo\u00a0extension method, available as a small NuGet package will make manually allocating buffers and other boilerplate associated &hellip; <a href=\"https:\/\/neosmart.net\/blog\/stuck-on-net-2-0-3-5-copy-streams-easily-with-this-nuget-extension\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":505,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[91,963,52,967],"class_list":["post-4092","post","type-post","status-publish","format-standard","hentry","category-software","tag-net","tag-nuget","tag-open-source","tag-stream-copyto"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4xDa-140","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/4092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/users\/505"}],"replies":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/comments?post=4092"}],"version-history":[{"count":4,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/4092\/revisions"}],"predecessor-version":[{"id":4590,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/4092\/revisions\/4590"}],"wp:attachment":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/media?parent=4092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/categories?post=4092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/tags?post=4092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}