Click here to Skip to main content
15,935,728 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to download a zip file and then extract to read it. Plz help
Posted
Comments
Sandeep Mewara 27-Jan-11 3:50am    
Did you try anything? Google?
himani_jha 27-Jan-11 5:23am    
public MainPage()
{
InitializeComponent();
Uri uri = new Uri("OnlineTv;component/example.zip", UriKind.Relative);

// Download the zip package.
WebClient webClient = new WebClient();
webClient.OpenReadAsync(uri);
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);


}
void webClient_OpenReadCompleted(object sender,
OpenReadCompletedEventArgs e)
{
// Extract the desired image from the zip package.
Stream zipPackageStream = e.Result;
Image image = LoadImageFromZipPackage(
"Tulips.jpg", zipPackageStream);
this.stackPanel.Children.Add(image);
}

public Image LoadImageFromZipPackage(
string relativeUriString, Stream zipPackageStream)
{
// Get the image stream at the specified URI that
// is relative to the application package root.
Uri uri = new Uri(relativeUriString, UriKind.Relative);
StreamResourceInfo zipPackageSri =
new StreamResourceInfo(zipPackageStream, null);
StreamResourceInfo imageSri =
Application.GetResourceStream(zipPackageSri, uri);

// Convert the stream to an Image.
BitmapImage bi = new BitmapImage();
bi.SetSource(imageSri.Stream);
Image img = new Image();
img.Source = bi;

return img;
}



Stream zipPackageStream = e.Result;
here I m getting error An exception occurred during a WebClient request
system.net.webexception
mayurdhwajsinh 10-Aug-11 3:02am    
Hi,

I am getting following error in the webClient_OpenReadCompleted event

{"An exception occurred during a WebClient request. "}
System.InvalidOperationException {System.Net.WebException}

Regards,
Mayur

Take a look here. This should get you started:
http://www.icsharpcode.net/opensource/sharpziplib/
 
Share this answer
 
Specialized port for SL and WP7 - http://slsharpziplib.codeplex.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900