0

I am struggling with C#, Ionic.Zip and the path declaration.
The error message is: The path format is not supported.
The path looks right, so no idea what's happening here...

This is my code:

string datetime = System.DateTime.Now.ToString("G");
datetime = String.Format("{0:yyyy_MM_dd}", datetime); 

string workingPath = @"C:\Users\udgru\Documents\Visual Studio 2013\Projects\Skeleton\Skeleton\bin\Debug";
string backupDir = System.IO.Path.Combine(workingPath, "UserData");
string outputFile = "Backup_" + datetime + ".zip";

MessageBox.Show(workingPath);
// Output: C:\Users\udgru\Documents\Visual Studio 2013\Projects\Skeleton\Skeleton\bin\Debug
MessageBox.Show(backupDir);
// Output: C:\Users\udgru\Documents\Visual Studio 2013\Projects\Skeleton\Skeleton\bin\Debug\UserData
MessageBox.Show(outputFile);
// Output: Backup_2015_03_04 17:26:44.zip

        try
        {
            using (ZipFile zip = new ZipFile())
            {

                zip.AlternateEncoding = Encoding.UTF8;
                zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always;
                zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
                zip.Comment = "This zip was created at " + datetime;
                zip.AddDirectory(backupDir);
                zip.Save(outputFile);

                MessageBox.Show("Backup successfully created.");

                FlyoutSettings.IsOpen = false;
            }
        }
        catch(Exception error)
        {
            MessageBox.Show(error.Message.ToString());
        } 
udgru
  • 1,277
  • 5
  • 14
  • 26

0 Answers0