EDIT : Here the code to use app data folder
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
GetDB();
}
void GetDB1()
{
var DBFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "DB1");
var con = new System.Data.SQLite.SQLiteConnection($"Data Source={DBFile}.sqlite;Version=3;");
con.Open();
string sql = "Select 1 as col1";
var command = new System.Data.SQLite.SQLiteCommand(sql, con);
var reader = command.ExecuteReader();
while (reader.Read())
Console.WriteLine("col1: " + reader["col1"]);
}
}
simply on window check your folder permissions like in pictures
more details
1. Software
software is a collection of data or computer instructions that tell the computer how to work
2. operating system software
An operating system (OS) is system software that manages computer hardware and software resources and provides common services for computer programs.
3. Directory structure
In computing, a directory structure is the way an operating system's file system and its files are displayed to the user. Files are typically displayed in a hierarchical tree structure.
4. Windows 10 [username]\AppData
This folder stores per-user application data and settings. The folder contains three subfolders: Roaming, Local, and LocalLow. Roaming is for networked based logins for roaming profiles. Data saved in Roaming will synchronize to the computer when the user logs into that. Local and LocalLow does not sync up with networked computer
5. Guidelines : Store and retrieve settings and other app data
App data is mutable data that is specific to a particular app. It includes runtime state, user preferences, and other settings.
App data is different from user data, data that the user creates and manages when using an app. User data includes document or media files, email or communication transcripts, or database records holding content created by the user. User data may be useful or meaningful to more than one app.
Often, this is data that the user wants to manipulate or transmit as an entity independent of the app itself, such as a document.
-Important note about app data: The lifetime of the app data is tied to the lifetime of the app. If the app is removed, all of the app data will be lost as a consequence. Don't use app data to store user data or anything that users might perceive as valuable and irreplaceable. We recommend that the user's libraries and Microsoft OneDrive be used to store this sort of information. App data is ideal for storing app-specific user preferences, settings, and favorites.
6.Access control
Access control refers to security features that control who can access files (resources) in the operating system (OS).
7.what is the relationship between operating system and application software
All Applications call access control functions on the operating system (OS) to access specific resources or control access to resources provided by the application.
So your App Need you as a user who has a control over the operation system to ask the operation system for Folder permission
So you need C# code + OS permission
8. How To apply this concepts
- 8.1. Run as administrator because they have accesses
- 8.2. Check the folder that the App is in
- 8.3. Add permission To the Folder for the current user
8.1. Run as administrator because they have accesses
8.1.1 How

8.1.2 Why

8.1.3 Why NoT
Why you shouldn’t run as admin… – Aaron Margosis' Non-Admin, App-Compat and Sysinternals WebLog
If the exploit happens to be written so that it requires admin privileges (as many do), just running as User stops it dead. But if you’re running as admin, an exploit can:
- install kernel-mode rootkits and/or keyloggers (which can be close to impossible to detect)
- install and start services
- install ActiveX controls, including IE and shell add-ins (common with spyware and adware)
- access data belonging to other users
- cause code to run whenever anybody else logs on (including capturing passwords entered into the Ctrl-Alt-Del logon dialog)
- replace OS and other program files with trojan horses
- access LSA Secrets, including other sensitive account information, possibly including account info for domain accounts
- disable/uninstall anti-virus
- cover its tracks in the event log
- render your machine unbootable
- if your account is an administrator on other computers on the network, the malware gains admin control over those computers as well
- and lots more
8.2. Check the folder that the App is in



8.3. Add permission To the Folder for the current user









Ref.