Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top