File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99using System . Threading . Tasks ;
1010using Newtonsoft . Json ;
1111using System . IO ;
12+ using System . Security . AccessControl ;
1213
1314namespace 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 ) )
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments