views:

46

answers:

1

Is there any deflate implementation for Silverlight 3 that is compatible with the .NET one?

Or, barring that, is there any similar compression algorithm available for both .NET and Silverlight I can use?

I tried this LZW example: http://paste.lisp.org/display/12198, but unfortunately it doesn't work very well.

+1  A: 

Silverlight can extract a file from a zip archive given a file name. .NET is capable of creating a Zip file. So assuming the direction is server->client (which it sounds like it is) you could use this client side code:-

 WebClient client = new WebClient();
 client.OpenReadCompleted => (s, args)
 {
    StreamResourceInfo zipInfo = new StreamResourceInfo(args.Result, null);
    StreamResourceInfo streamInfo = Application.GetResourceStream(zipInfo, new Uri("myfile.dat", UriKind.Relative));
    YourFunctionToProcessTheDecompressedStream(streamInfo.Stream);
 }
 client.OpenRead(new Url("http://yourserver/somehandler.ashx"));

The "somehandler.ashx" could take some input stream and store it in a zip archive as "myfile.dat" sending the resulting zip to the response.

AnthonyWJones
Ai, nice, this looks mighty promising! I'll take a look when I'm back on work on tuesday.
Lasse V. Karlsen
This worked like a charm.
Lasse V. Karlsen