By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,326 Members | 881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,326 IT Pros & Developers. It's quick & easy.

Change Database FileName And Copy Into Existing Folder

P: n/a

Using vb.net

Hello. Here is the problem that I am having. I have a program which
makes a copy of my working database (wasa.mdb) and saves it to another
folder (/bin/backup/) with the filename (9-27-2005,1210PM.mdb) *Note
This Is The Current System Date And Time Of The Save.*

I would like to have the function where when the user selects The
"Restore Database" button (btnRestore) that it will use an Open File
Dialog box and let them select which version of the database they would
like to use for the restore. Then I need the functionallity where once
the database version is selected, it will rename the
(9-27-2005,1210PM.mdb) to (wasa.mdb) so that my application can use the
database. It can overwrite the current file as I will throw the
functionallity to save the database before the restore. Can anyone help?

Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I forgot to add this although some might realize it. I need the renamed
file (wasa.mdb) to be inserted back into the /bin/ folder where my
application is run. Thanks !

Nov 21 '05 #2

P: n/a
Hi,

Take a look at File.Copy method, e.g.:

~
File.Copy(OpenFileDialog1.FileName,
Path.Combine(Application.StartupPath, "wasa.mdb"), True) REM Untested
~

HTH,
Roman

"Webbyz" <ma*******@gmail.com> ???????/???????? ? ???????? ?????????:
news:11**********************@o13g2000cwo.googlegr oups.com...
I forgot to add this although some might realize it. I need the renamed file (wasa.mdb) to be inserted back into the /bin/ folder where my
application is run. Thanks !

Nov 21 '05 #3

P: n/a
I used the code and I imported System.IO and here is the error I got..

An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll

Additional information: Empty file name is not legal.

What's up with that?

Nov 21 '05 #4

P: n/a
Have you already shown your OpenFileDialog?

Sample:

~
Dim ofp As New OpenFileDialog
ofp.Filter = "Access Databases (*.mdb)|*.mdb"
If ofp.ShowDialog(Me) = DialogResult.OK Then
File.Copy(ofp.FileName,
Path.Combine(Application.StartupPath, "wasa.mdb"), True)
MessageBox.Show("You restored a backup: " &
Path.GetFileName(ofp.FileName))
Else
MessageBox.Show("User doesn't want to restore a backup!")
End If
~

Roman

"Webbyz" <ma*******@gmail.com> ???????/???????? ? ???????? ?????????:
news:11*********************@g49g2000cwa.googlegro ups.com...
I used the code and I imported System.IO and here is the error I got..

An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll

Additional information: Empty file name is not legal.

What's up with that?

Nov 21 '05 #5

P: n/a
Dragon You Rock! Works like a charm. Thanks a bunch!

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.