L
Logan Montgomery
Guest
Hi so I am really new to coding with C# and I am trying to extract a file with C#, however I keep getting the same errors listed below!
Error CS0234 The type or namespace name 'FileSystem' does not exist in the namespace 'System.IO.Compression' (are you missing an assembly reference?) LoganUtilitesInstaller C:\Users\logan\source\repos\LoganUtilitesInstaller\LoganUtilitesInstaller\Form1.cs 3 Active
and
Error CS0234 The type or namespace name 'FileSystem' does not exist in the namespace 'System.IO.Compression' (are you missing an assembly reference?) LoganUtilitesInstaller C:\Users\logan\source\repos\LoganUtilitesInstaller\LoganUtilitesInstaller\Properties\AssemblyInfo.cs 2 Active
I have already added a reference to System.IO.Compression and to System.IO.Compression.FileSystem
Below is my code to the entire program:
using System;
using System.IO.Compression;
using System.IO.Compression.FileSystem;
using System.IO;
using System.Net;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace LoganUtilitesInstaller
{
public partial class Form1 : Form
{
public object ZipFile { get; private set; }
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void installbutton_Click(object sender, EventArgs e)
{
{
Thread thread = new Thread(() => {
WebClient client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
client.DownloadFileAsync(new Uri("https://github.com/LoganMontgomery/LoganUtilitesInstaller/raw/master/loganutilites.zip"), @"C:\loganutilites.zip");
});
thread.Start();
};
}
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.BeginInvoke((MethodInvoker)delegate {
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
downloadprogresstext.Text = "Downloaded " + e.BytesReceived + " of " + e.TotalBytesToReceive;
downloadprogressbar.Value = int.Parse(Math.Truncate(percentage).ToString());
});
}
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
Directory.CreateDirectory(@"C:\LoganUtilites");
string extractFolder = @"c:\LoganUtilites";
string zipFile = @"c:\LoganUtilites.zip";
ZipFile.ExtractToDirectory (zipFile, extractFolder);
this.BeginInvoke((MethodInvoker)delegate {
downloadprogresstext.Text = "Completed";
});
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
I hope this enough information, Thanks In Advance!
Continue reading...
Error CS0234 The type or namespace name 'FileSystem' does not exist in the namespace 'System.IO.Compression' (are you missing an assembly reference?) LoganUtilitesInstaller C:\Users\logan\source\repos\LoganUtilitesInstaller\LoganUtilitesInstaller\Form1.cs 3 Active
and
Error CS0234 The type or namespace name 'FileSystem' does not exist in the namespace 'System.IO.Compression' (are you missing an assembly reference?) LoganUtilitesInstaller C:\Users\logan\source\repos\LoganUtilitesInstaller\LoganUtilitesInstaller\Properties\AssemblyInfo.cs 2 Active
I have already added a reference to System.IO.Compression and to System.IO.Compression.FileSystem
Below is my code to the entire program:
using System;
using System.IO.Compression;
using System.IO.Compression.FileSystem;
using System.IO;
using System.Net;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace LoganUtilitesInstaller
{
public partial class Form1 : Form
{
public object ZipFile { get; private set; }
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void installbutton_Click(object sender, EventArgs e)
{
{
Thread thread = new Thread(() => {
WebClient client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
client.DownloadFileAsync(new Uri("https://github.com/LoganMontgomery/LoganUtilitesInstaller/raw/master/loganutilites.zip"), @"C:\loganutilites.zip");
});
thread.Start();
};
}
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.BeginInvoke((MethodInvoker)delegate {
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
downloadprogresstext.Text = "Downloaded " + e.BytesReceived + " of " + e.TotalBytesToReceive;
downloadprogressbar.Value = int.Parse(Math.Truncate(percentage).ToString());
});
}
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
Directory.CreateDirectory(@"C:\LoganUtilites");
string extractFolder = @"c:\LoganUtilites";
string zipFile = @"c:\LoganUtilites.zip";
ZipFile.ExtractToDirectory (zipFile, extractFolder);
this.BeginInvoke((MethodInvoker)delegate {
downloadprogresstext.Text = "Completed";
});
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
I hope this enough information, Thanks In Advance!
Continue reading...