0

Hi all...
I hope you have good time ....
I have problem in the new program and I want to your help ..
I want to back up the database type from Access, but my problem I could not generate code to determine the path of the database, I noticed that the database path (C: \ Users \ george \ AppData \ Local \ Apps \ 2.0 \ Z1KL8MCD.3ET \ 62KCKET3.2TX )
But this path is changed when the program re-installation ( final folder change as it is known)
note, I use Windows 7 & Microsoft Visual Studio 2010 ...
note , I use this code >> but does not work >>>

Dim FileSystemObject = CreateObject("Scripting.FileSystemObject")
FileSystemObject.copyfile(app.path & "\HamakDatabase", TextBox1.Text)

Please I need code to specify the path to the database (Access), which you have linked to my program. ..
Thank you very much.....

Edited by george8

3
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by Sahil89
0

I'm so sorry , please delete this topic,
I made a mistake spelling ^__^ (I replace App.path with Application.StartupPath)
And it solve my problem ....

0

One alternative is to place an open file dialog in the project, then allow the user to navigate to the data base.

You will:

1) Place the dialog
2) Do some coding to prevent empty paths
3) Store the value from the dialog on the form.
4) Create a backup button that will execute the backup.

You can also ad a Folder Browser Dialog to the project, to allow the user to chose where the backup will be placed

Code example:

    Dim SourceDir As String
    Dim DestDir As String


    If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
        If OpenFileDialog1.FileName <> "" Then
            SourceDir = OpenFileDialog1.FileName
        End If
    End If

    If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
        If FolderBrowserDialog1.SelectedPath <> "" Then
            If IO.Directory.Exists(FolderBrowserDialog1.SelectedPath) Then
                DestDir = FolderBrowserDialog1.SelectedPath & "/" 'Must add the / to end.'
            End If
        End If
    End If
0

I'm so sorry , please delete this topic,
I made a mistake spelling ^__^ (I replace App.path with Application.StartupPath)
And it solve my problem ....

I tried Application.StartupPath but it dont work.
My.Application.Info.DirectoryPath this what I use and it gives the path of the application.

0

I tried Application.StartupPath but it dont work.
My.Application.Info.DirectoryPath this what I use and it gives the path of the application.

my friend ... it work with me
note , I use Microsoft Visual Studio 2010
I will give you my code
Here is ...

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If TextBox1.Text > "" Then
            Timer1.Start()
            FileSystemObject = CreateObject("Scripting.FileSystemObject")
            FileSystemObject.copyfile(Application.UserAppDataPath & "\Dabase.mdb", TextBox1.Text & ".mdb")
        Else
            MsgBox("select path please ...")
        End If
    End Sub

my friend note that "Application.UserAppDataPath " return database path but "Application.StartupPath "
return the application path .....
I hope I help you

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.