https://github.com/karenpayneoregon/copy-db-postbuild-vb
Learn an alternate method to provide a new local database available within the application folder rather than dynamically creating a new database at runtime.
https://github.com/karenpayneoregon/copy-db-postbuild-vb
database post-build technet-article vb-net
Last synced: over 1 year ago
JSON representation
Learn an alternate method to provide a new local database available within the application folder rather than dynamically creating a new database at runtime.
- Host: GitHub
- URL: https://github.com/karenpayneoregon/copy-db-postbuild-vb
- Owner: karenpayneoregon
- Created: 2020-05-29T20:02:47.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-29T21:00:56.000Z (about 6 years ago)
- Last Synced: 2025-01-29T00:30:14.159Z (over 1 year ago)
- Topics: database, post-build, technet-article, vb-net
- Language: Visual Basic .NET
- Homepage:
- Size: 155 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# About
When a VB.NET project (same can be easily done in C# also) requires a file or database to replace when missing, or never existed, the common idea is to create the database at runtime. Creating a database means extra libraries will be needed along with the possibility of failure. Rather than do this at runtime this repository offers an alternate method which is to place a safe copy of a database in a sub folder of the application, when needed copy to the application folder. A key aspect of this method involves several items to be in place which are discussed in an upcoming TechNet article.
[Microsoft TechNet article](https://social.technet.microsoft.com/wiki/contents/articles/53901.copy-files-post-build-in-visual-studio.aspx)
- Will work with any file type
- Leaves off where copy to output folder ends

```
FileHelper.CopyDatabase(True)
If Not FileHelper.IsSuccessFul Then
If FileHelper.DatbaseInuse Then
MessageBox.Show("Please close the database and try again")
Else
MessageBox.Show(FileHelper.LastExceptionMessage)
End If
Else
```