1
How to Extract Zip Files in c# to a folder where the system is installed?
using System;
using System.IO.Compression;
using System.Windows;
using System.Xml;
namespace TestXml
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
string Dir2 = @"c:\IASD\Cantina Escolar\";
XmlDocument doc = new XmlDocument();
doc.Load("http://www.meusite.com/arquivoXML.xml");
XmlNode node = doc.DocumentElement.SelectSingleNode("/Application/Version");
XmlNode node1 = doc.DocumentElement.SelectSingleNode("/Application/ZipFile");
string version = node.InnerText;
string zipfile = node1.InnerText;
string End = "http://www.meusite.com/";
string Arq = version;
string file = zipfile;
string Arquivo = String.Concat(End, zipfile);
string Arquivo2 = String.Concat(@"c:\IASD\Cantina Escolar\",zipfile);
WebClient webClient = new WebClient();
webClient.DownloadFile(Arquivo, @"C:\IASD\Cantina Escolar\"+zipfile);
ZipFile.ExtractToDirectory(Arquivo2, zipfile);
}
}
}
The error message displayed is:
URI formats are not supported.
So to summarize:
I go to the server and put a zip, which is an update to be downloaded. I manually change the XML file by placing the version of the file, which is nothing more than the name of the file to be unzipped. The method reads XML and has to download and unzip the zip file in the system installation folder.
Could you help me?
You are making some confusion, as far as I understand about your problem is that you want to unzip a file that will be available in an online url. It turns out that you need to first download that file to your local disk, only then extract that file.
– iuristona
I download it only that it does not go to the folder where I determined it to be. It is going to the folder bin Debug. am downloading with Webclient Webclient = new Webclient(); Webclient.Downloadfile(File,@"c: Directory folder is creating a folder with the file name and not unzipping the file directly in the directory I determined.
– Paulo Romeiro
Paste your complete code by downloading the file.
– iuristona
I have no punctuation to answer the question itself and here it is unviable.
– Paulo Romeiro
I’ll have to make another answer.
– Leonel Sanches da Silva