Skip to content

Commit 69557e8

Browse files
committed
Changed database saving dir to app data
1 parent 85bac7e commit 69557e8

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

CutCode/DataBase/DataBaseManager.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Threading.Tasks;
1010
using Newtonsoft.Json;
1111
using System.IO;
12+
using System.Security.AccessControl;
1213

1314
namespace CutCode
1415
{
@@ -19,12 +20,17 @@ public class DataBaseManager : IDataBase
1920
private SQLiteConnection _db;
2021
private readonly IThemeService themeService;
2122

22-
private string prefpath = "pref.json";
23+
private string prefpath { get; set; }
2324
#region Set region
2425
public DataBaseManager(IThemeService _themeService)
2526
{
26-
var path = "DataBase.db";
27-
_db = new SQLiteConnection(path);
27+
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
28+
var path = Path.Combine(appDataPath, "CutCode");
29+
Directory.CreateDirectory(path);
30+
var dbpath = Path.Combine(path, "DataBase.db");
31+
prefpath = Path.Combine(path, "pref.json");
32+
33+
_db = new SQLiteConnection(dbpath);
2834
_db.CreateTable<CodeTable>();
2935

3036
if (File.Exists(prefpath))

CutCode/ViewModels/MainViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class MainViewModel : Screen
2323
public static List<Object> Pages;
2424
private readonly IThemeService _themeService;
2525
private readonly IPageService pageService;
26-
private readonly IDataBase database;
2726
public ObservableCollection<SideBarBtnModel> sideBarBtns { get; set; }
2827
public MainViewModel(IThemeService themeService, IPageService _pageService, IDataBase _dataBase)
2928
{

0 commit comments

Comments
 (0)