Deploy VB.Net Winforms App with Sqlite DB
Ok... Gone are the VB6 days where we could create a folder (data) in the application directory and stick our database in there (c:\program files\myApplication\Data\MyAppData.s3db). I don't want to use vb.net with Sql Server! In .Net I am aware of the special folders and the the User Application Data folders. If I add that type of folder to my package and deployment project and include the file that is our blank database, the folder will be created and the db will not be in there. If I use the Application Data folders I loose the write ability as the folders and all sub files are readonly. I'm stuck. I can't create开发者_运维问答 a new folder in the C:\Program Files (x 86)in code and then create the db from scratch through running create table queries for each table. What would be good application deployment? No one seems to have an answer for this one. Any help would be appreciated.
If I use the Application Data folders I loose[sic] the write ability as the folders and all sub files are readonly
There is an All Users Application Data folder that is readonly and a separate Application Data folder for each user. The per-user Application Data folders are not readonly — you can write to them.
What I normally do is deploy a blank data file to my Program Files folder, and copy this file to the user's App Data folder when the user runs my app for the first time.
The global Application Data folder is read-only for non-admin users. But every user has their own Application Data folder which you can definitely write to and is the preferred place for storing application-specific data. Unfortunately, these folders are hidden by default.
精彩评论