简体   繁体   中英

WPF C# Installed application SQLite database location

I have just compiled and installed an application that generates and uses an SQLite database.

In my App.config file, my connection string is like this:

<add name="DBContext" connectionString="data source=.\DB.sqlite" providerName="System.Data.SQLite" />

In my debug/release, I can see that the DB.sqlite file is created in the same folder.

However, when I have installed the compiled application, it goes to a directory called:

C:\Users\uua\AppData\Local\VirtualStore\Program Files (x86)\App

Is there a way to make sure the database appears in a custom location or in the same folder as my installed application?

Is there a way to make sure the database appears in a custom location or in the same folder as my installed application?

You could always use an absolute path:

<add name="DBContext" connectionString="data source=c:\folder\DB.sqlite" providerName="System.Data.SQLite" />

The obvious drawback with this is that you need to make sure that the directory actually exists on the machine(s) where your app is installed.

You may want to consider setting the connection string programmatically .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM