0

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?

JianYA
  • 2,750
  • 8
  • 60
  • 136
  • Is your application executable signed? Why not just install the application, or database, to the local user profile? – ProgrammingLlama Jun 16 '20 at 09:27
  • 1
    Why you think that you can right to write file there? Without admin right application can't write to Program Files ... If access to the db file is crucial for user make an option to open this folder from the app for them – Selvin Jun 16 '20 at 09:28

1 Answers1

0

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.

mm8
  • 163,881
  • 10
  • 57
  • 88