File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ #if NET20 || NET35
2+
3+ using System ;
4+ using System . IO ;
5+
6+ namespace BinaryObjectScanner
7+ {
8+ /// <summary>
9+ /// Derived from the mscorlib code from .NET Framework 4.0
10+ /// </summary>
11+ internal static class OldDotNet
12+ {
13+ public static void CopyTo ( this Stream source , Stream destination )
14+ {
15+ if ( destination == null )
16+ {
17+ throw new ArgumentNullException ( "destination" ) ;
18+ }
19+
20+ if ( ! source . CanRead && ! source . CanWrite )
21+ {
22+ throw new ObjectDisposedException ( null ) ;
23+ }
24+
25+ if ( ! destination . CanRead && ! destination . CanWrite )
26+ {
27+ throw new ObjectDisposedException ( "destination" ) ;
28+ }
29+
30+ if ( ! source . CanRead )
31+ {
32+ throw new NotSupportedException ( ) ;
33+ }
34+
35+ if ( ! destination . CanWrite )
36+ {
37+ throw new NotSupportedException ( ) ;
38+ }
39+
40+ byte [ ] array = new byte [ 81920 ] ;
41+ int count ;
42+ while ( ( count = source . Read ( array , 0 , array . Length ) ) != 0 )
43+ {
44+ destination . Write ( array , 0 , count ) ;
45+ }
46+ }
47+ }
48+ }
49+
50+ #endif
You can’t perform that action at this time.
0 commit comments