Backup of an Access Database

jeva39

Well-known member
Joined
Jan 28, 2005
Messages
135
Location
Panama
Programming Experience
1-3
I use an Access Database. In VB.NET, within the application (with a Button or Menu Option) how I can to make a Backup of the .MDB file in a specific Backup directory?

Thanks!
 
Thanks for your help. Problem solved. If somebody need the complete code,this is an example. Works fine!!

Need two Buttons or Two Menu Options, a TextBox for the name of directory and a OpenFileDialog control:

VB.NET:
Imports System.IO
................................

Private Sub mnuCrearDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCrearDir.Click
	Try
	  Directory.CreateDirectory(TextBox1.Text)
	  'Creating a directory by specifying a path in the TextBox, of the form c:\examples
	  'Instead of using a TextBox you can directly type the location of the directory like this
	  'Directory.CreateDirectory("c:\examples")
	  MsgBox("Directory created OK!")
	Catch
	  ....................
	End Try
	
  End Sub

Private Sub mnuCopiarArchivo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopiarArchivo.Click
	Try
	  If OpenFileDialog1.ShowDialog <> DialogResult.Cancel Then
		File.Copy(OpenFileDialog1.FileName, TextBox1.Text & "\" & _
		OpenFileDialog1.FileName.Substring(OpenFileDialog1.FileName.LastIndexOf("\")))
		'The above line of code uses OpenFileDialog control to open a dialog box where you
		'can select a file to copy into the newly created directory
	  End If
	  MsgBox("File Copied Successfully")
	Catch
	 ......................
	End Try
	
  End Sub
 
Back
Top