Question

I'm working on a Windows Forms application that has connection with an Access database. I need to create a backup for that database. Also, user has to choose the destination folder of the backup. Can someone give me a help on this?

Thanks

Was it helpful?

Solution

You can use option of simply copying your access DB file to another location as a backup.

It can be done as follows:

File.Copy(sourceDbName, destDbName, true);

OR

You can add a simple routine that takes your input database, zip and store it, in your backup directory, optionally passing a password, like this:

using Ionic.Zip;
......

private void BackupToZip(string sourceDBName, string destZipFile, string password)
{
    using (ZipFile zipF = new ZipFile(destZipFile))
    {
        if (bkpPass.Length > 0) zip.Password = password;
        ZipEntry ze = zip.UpdateFile(sourceDbName, string.Empty);
        ze.Comment = "Working copy stored in date: " + DateTime.Today.ToShortDateString();
        zipF.Comment = "This zip archive has been created by ......";
        zipF.Save();
    }
}

Can Refer Following link for more snipets:

http://dotnetzip.codeplex.com/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top