Question:
How to copy a database file to another location using visual basic?
token
2009-03-04 03:58:58 UTC
hi
I want to copy my database file to another location and rename it when it is pasted in the new location using visual basic. Sort of like a backup
Three answers:
MarkG
2009-03-04 05:40:28 UTC
Use two dialog boxes (OpenFileDialog & SaveFileDialog) .filename property to determine the oldPath and newPath (string variables )



Use the System.IO.File object to expose methods for testing if the file exists and the Copy method.



Test if the file in the newPath already exists and if so prompt user to delete it or not. If OK to delete then use Delete method



finally use copy method



System.IO.File.Copy(origPath, newPath)





Use error handling to trap errors either an OnError Goto OR TRY/Catch. Most likely errors will involve the effected files being already open by some other program in which case your program should gracefully pro,prompt the user to close other programs and try again.





EDIT:



You can use the System.IO.Path object to easily extract parts of the existing .filename into string variables so that you can reassemble a new filename(with path) that utilizes some default naming system. Like adding "_BACKUP" to the beginning or end of the filename and defining a standardized directory or use the same directory. This automates the naming portion of the copy process and means the user doesn't have to manually browse and name the copied filename (path) but only selected which file to backup.
?
2016-10-04 17:48:44 UTC
you could attempt and do a "present day undertaking" seek via code view. type F7 on any form, and then type Ctrl+F to open the discover communique. in case you nonetheless cant discover it it would be an ADODC connection administration someplace in the form. sturdy success :)
SeeYouLater_Zee
2009-03-04 04:15:26 UTC
http://www.homeandlearn.co.uk/NET/nets8p6.html

http://msdn.microsoft.com/en-us/library/5w05844e(VS.80).aspx

http://msdn.microsoft.com/en-us/library/5w05844e.aspx


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...