1

Closed

Tools/WinFormApp does not correctly create split archives

description

The sample DotNetZip Win Forms App allows the selection of split size when creating archives, but the selection is not used, and becomes "-none-". Bug is improper parsing of the menu selection text. For example, the text of the actual selections end with "kb", but the parsing code only handles endings with "k" or "m". There's more terse ways to express this, but a possible suggested code replacement (v 1.9.1.5) is to ZipForm.cs approx line 322. Also supports "GB".
        string arg = this.comboSplit.SelectedItem.ToString().ToUpper();
 
        try
        {
            if (arg.EndsWith("K"))
                options.MaxSegmentSize = Int32.Parse(arg.Substring(0,arg.Length-1)) * 1024;
            else if (arg.EndsWith("KB"))
                options.MaxSegmentSize = Int32.Parse(arg.Substring(0, arg.Length - 2)) * 1024;
            else if (arg.EndsWith("M"))
                options.MaxSegmentSize = Int32.Parse(arg.Substring(0,arg.Length-1)) * 1024 * 1024;
            else if (arg.EndsWith("MB"))
                options.MaxSegmentSize = Int32.Parse(arg.Substring(0, arg.Length - 2)) * 1024 * 1024;
            else if (arg.EndsWith("G"))
                options.MaxSegmentSize = Int32.Parse(arg.Substring(0, arg.Length - 1)) * 1024 * 1024 * 1024;
            else if (arg.EndsWith("GB"))
                options.MaxSegmentSize = Int32.Parse(arg.Substring(0, arg.Length - 2)) * 1024 * 1024 * 1024;
            else
                options.MaxSegmentSize = Int32.Parse(arg);
        }
        catch
        {
            // just reset to "none"
            this.comboSplit.SelectedIndex = 0;
            options.MaxSegmentSize = 0;
        }
Closed Jun 14, 2011 at 5:20 AM by Cheeso
fixed in changeset 79086. First binary with this fix: v1.9.1.6

comments

Cheeso wrote Jun 14, 2011 at 5:18 AM

Good bug, thanks for catching this.