If someone could tell me if there is a function or method, or some way of finding the directory that the VB project loads to when it is installed on other computers that would be great. What I want it for is so that I can save and restore a database dynamically.
Currently I am saving it to a directory that I know where it is (C:/Program Files/PortGen2.0) Which allows me to save it, but not restore it because I don't know where to load the file if something were to happen to the old one.
Any help is appreciated, some technical info is: VB 2005 Express, Access 2003 Database, and the code I am using right now for restoreDB()
Public Sub restoreDB() Dim backupName As String Dim portfolioDBName As String = portfolioDBPath + "portfolioDB.mdb" Dim fdlg As OpenFileDialog = New OpenFileDialog() fdlg.InitialDirectory = portfolioDBPath + "\backup" If fdlg.ShowDialog() = Windows.Forms.DialogResult.OK Then backupName = fdlg.FileName If MessageBox.Show("Restoring the database will erase any changes you have made since your last backup. Are you sure you want to do this?", _ "Confirm Delete", _ MessageBoxButtons.OKCancel, _ MessageBoxIcon.Question, _ MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then 'Restore the database from a backup copy. FileCopy(backupName, portfolioDBName) MsgBox("Database Restoration Successful") End If End If End Sub