Skip to content

Commit 6c74b1e

Browse files
JosipJosip
authored andcommitted
Stream.CopyTo replaced with our own CopyStream method. This allows us to compile Ghostscript.NET for .NET 3.5 and lower.
1 parent 1a7c445 commit 6c74b1e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Ghostscript.NET/Helpers/StreamHelper.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,32 @@ public static string WriteToTemporaryFile(Stream stream)
148148

149149
using (FileStream fs = File.Create(path))
150150
{
151-
stream.CopyTo(fs);
151+
CopyStream(stream, fs);
152152
}
153153

154154
return path;
155155
}
156156

157157
#endregion
158158

159+
#region CopyStream
160+
161+
public static void CopyStream(Stream input, Stream output)
162+
{
163+
int size = (input.CanSeek) ? Math.Min((int)(input.Length - input.Position), 0x2000) : 0x2000;
164+
165+
byte[] buffer = new byte[size];
166+
167+
int n;
168+
169+
do
170+
{
171+
n = output.Read(buffer, 0, buffer.Length);
172+
output.Write(buffer, 0, n);
173+
} while (n != 0);
174+
}
175+
176+
#endregion
177+
159178
}
160179
}

0 commit comments

Comments
 (0)