Question

I have developed a little software for Windows few weeks now and got problems when trying to make proper installer for it. I got spesific request that database file has to be in same folder where program is so user can take own backups every now and then.

When I install it (using Visual Studio 2012 and InstallShield Limited Edition project) it works in my main computer(W7 64-bit), my laptop(W8 64-bit) and my buddys Laptop(W8 32-bit) just fine.

My main computer runs program as it should, it uses database file from programs Database -folder(C:/Program Files (x86)/Program Name/Program Name/Database) and doesnt create additional db files but my laptop and my friends laptop create folder to "C:/Users/User/AppData/Local/VirtualStore/Program Files (x86)/Program Name/Program Name/Database" and use database from there.

Also I noticed that program crash on start on my other test computer that runs W7 32-bit and I made sure that .Net Framework was installed.

Connection string goes like: sqLiteConnection1.ConnectionString = "data source=.\\Database\\db"; Program's Platform target is set to Any CPU and it uses .Net Framework 4.5 if that helps anything.

Any ideas whats causing this and how I can fix it?

Was it helpful?

Solution

database file has to be in same folder where program is so user can take own backups

Danger Will Robinson! Non-admin users cannot modify files in the shared or Program Files folder. You are forcing users to run as Admins, or change the Program Files folder so non-Admins can modify it; both are serious security vulnerabilities.

If you install the database to the Programs folder, then the database is part of the install and not user data. This means that repairing or uninstalling the application will delete all user data. Users don't like that.

Your application should copy the application database to a user folder like Environment.SpecialFolder.ApplicationData and save all changes there. All users can modify and backup data from their own folders, no security vulnerabilities required. Also, when someone repairs or uninstalls the application, all users get to keep their data.

OTHER TIPS

Your connection string is using current directory (.).

Create it dynamically with Assembly.GetExecutingAssembly().Location.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top