开发者

how to zip the file using ionic library

I have done this one for backup my database its working fine ....

    private void backupDatabase()
    {

        txtbackup.AppendText("Starting Backup...");    
        Process sd = null;
        const  string backupcmd = @"C:\wamp\www\access\mysqldump.exe";
        string filepath = @"C:\folder\Access\";
        string dbHost = "local";
        string dbuser = "root";
        string dbName = "access";
        string backupName = "Backup.sql";
        ProcessStartInfo r1 = new ProcessStartInfo(backupcmd, string.Format("-h {0} -u {1} {2} -r {3}", dbHost, dbuser, dbName, backupName));


        r1.CreateNoWindow = true;
        r1.WorkingD开发者_如何学Cirectory = filepath;
        r1.UseShellExecute = false;
        r1.WindowStyle = ProcessWindowStyle.Minimized;
        r1.RedirectStandardInput = false;

        sd = Process.Start(r1);
         sd.WaitForExit();

        if (!sd.HasExited)
        {
             sd.Close();
        }
        sd.Dispose();
        r1 = null;
        sd = null;
        txtbackup.Clear();
        txtbackup.AppendText("Backup is Finished");

    } 

its working fine ...but i want to store the backup.sql as a zip file in this path

@"C:\folder\Access\";

i have got this library Ionic.Zip.Reduced but i dont know how to zip the file and stored in the given path....


The library is pretty simple to use :

using (var zip = new ZipFile())
{
    zip.AddFile("Backup.sql");

    zip.Save(@"C:\folder\Access\"Backup.zip");
}

And even their homepage contains samples good enough for your use.


You should use this compression library or this one may be an option?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜