3

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

1
  • Add some code to your question indicating what you have tried. Commented May 13, 2013 at 6:28

1 Answer 1

2

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.