0

I am writing a program that downloads files and sends the files over to a selected drive on the PC of the users choice. I have a ComboBox that lists drives by their letters, however I cannot get the files to send over to the USB.

I have tried just manually with the drive letter:

ZipFile.ExtractToDirectory(@"./temp/setup.zip", @"H:\");

I have tried when the drive is set as a string as well. I get no error message, my program just freezes.

If anybody could give me a hand, that would be amazing!

EDIT: I am now getting this exception after a change I have made:

Split or spanned archives are not supported

I am getting this exception after the program just freezes for about 30 seconds.

Here is the change I made to my code:

private void startbutton_Click(object sender, EventArgs e)
{
    if (devicepath == null)
    {
        MessageBox.Show("Select a device before continuing.", "Xub Error", 
            MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    else if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
    {
        if (Directory.Exists(@"./temp") == false)
        {
            Directory.CreateDirectory(@"./temp");
        }

        File.Move(@"./setup.xub", @"./temp/setup.zip");

        // It is freezing on the line below:
        ZipFile.ExtractToDirectory(@"./temp/setup.zip", 
            folderBrowserDialog1.SelectedPath);
    }
}
Enigmativity
  • 113,464
  • 11
  • 89
  • 172
Jordan G
  • 1
  • 1
  • Does this answer your question? [how do I copy a folder to a USB? C#](https://stackoverflow.com/questions/11987230/how-do-i-copy-a-folder-to-a-usb-c-sharp) – sous2817 Sep 02 '21 at 21:06
  • Are you able to extract to a folder you know you have access to? Is the code inside a `try/catch` block? – 001 Sep 02 '21 at 21:08
  • 1
    If your program freezes, then I assume it's because you're performing this operation on the main thread and the operation is still running. (You could perform this operation in a background/worker thread) Did it create _any_ of the files? Are you sure it isn't throwing an exception? Is this a windows forms app? (which may be eating your exception.) – Wyck Sep 02 '21 at 21:13
  • Split or spanned archives are not supported.' I am now getting this exception – Jordan G Sep 02 '21 at 21:33
  • How big is this file? The original zip file format couldn't handle files above 4GB. I think split/spanned archives are kind of an extension on the zip format which allows for larger files, but it isn't supported by the built-in ZipFile type. Consider using DotNetZip instead? See https://stackoverflow.com/q/43199435/120955 – StriplingWarrior Sep 02 '21 at 22:34

0 Answers0