How to extract zip files in c # to a folder where is the system 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 summarizing:
I go on the server and put a zip, which is an update to be downloaded. 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 the XML and has to download and unzip the zip file in the system installation folder.
Could you help me?