c# - Using .NET GZipStream Class with Mono -
i'm trying build example gzipstream class. command gmcs gzip.cs
, got error messages. gzip.cs same source msdn.
it seems need add reference when compiling. what's missing?
gzip.cs(57,32): error cs1061: type `system.io.filestream' not contain definition `copyto' , no extension method `copyto' of type `system.io.filestream' found (are missing using directive or assembly reference?) /library/frameworks/mono.framework/versions/2.10.1/lib/mono/2.0/mscorlib.dll (location of symbol related previous error) gzip.cs(86,40): error cs1061: type `system.io.compression.gzipstream' not contain definition `copyto' , no extension method `copyto' of type `system.io.compression.gzipstream' found (are missing using directive or assembly reference?) /library/frameworks/mono.framework/versions/2.10.1/lib/mono/gac/system/2.0.0.0__b77a5c561934e089/system.dll (location of symbol related previous error) compilation failed: 2 error(s), 0 warnings
solved
i should use 'dmcs', not 'gmcs' in order use .net 4 functions.
stream.copyto
arrived in .net 4 - may not in mono yet (or perhaps need more recent version).
it's easy write similar extension method though:
public static class streamextensions { public static void copyto(this stream input, stream output) { byte[] buffer = new byte[16 * 1024]; int bytesread; while ((bytesread = input.read(buffer, 0, buffer.length)) > 0) { output.write(buffer, 0, bytesread); } } }
Comments
Post a Comment