Skip to content

Commit d6211fd

Browse files
committed
fixe database path
1 parent 3f97180 commit d6211fd

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

fast cf ip scanner/Constants.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,33 @@ public static class Constants
1313
SQLite.SQLiteOpenFlags.Create |
1414
// enable multi-threaded database access
1515
SQLite.SQLiteOpenFlags.SharedCache;
16-
17-
public static string DatabasePath =>
18-
Path.Combine("C:\\Users\\azata\\Desktop\\db test", DatabaseFilename);
16+
//#if WINDOWS
17+
// public static string DatabasePath =>
18+
// Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),"fast cf ip scanner", DatabaseFilename);
19+
//#endif
20+
//#if ANDROID
21+
// public static string DatabasePath =>
22+
// Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), DatabaseFilename);
23+
//#endif
24+
public static string GetDatabasePath()
25+
{
26+
#if WINDOWS
27+
string platformFolder = "Fast-CF-IP-Scanner";
28+
#else
29+
string platformFolder = ""; // Adjust if needed for Android
30+
31+
#endif
1932

33+
string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), platformFolder);
34+
string databasePath = Path.Combine(appDataPath, DatabaseFilename);
35+
36+
if (!Directory.Exists(appDataPath))
37+
{
38+
Directory.CreateDirectory(appDataPath);
39+
}
40+
41+
return databasePath;
42+
}
2043
public static List<string> HttpPorts
2144
{
2245
get

fast cf ip scanner/Data/FastCFIPScannerDatabase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ async Task Init()
1111
{
1212
if (DataBase is not null)
1313
return;
14-
15-
DataBase = new SQLiteAsyncConnection(Constants.DatabasePath, Constants.Flags);
14+
DataBase = new SQLiteAsyncConnection(Constants.GetDatabasePath(), Constants.Flags);
1615
await DataBase.CreateTableAsync<IPModel>();
1716
await DataBase.CreateTableAsync<WorkerModel>();
1817

fast cf ip scanner/Views/ScanPage.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
<StackLayout Padding="15"
5656
Orientation="Horizontal"
5757
Spacing="10">
58-
<Label Text="ip : " TextColor="White" />
58+
<Label Text="ip :" TextColor="White" />
5959
<Label Text="{Binding IP}" TextColor="White" />
60-
<Label Text="ping : " TextColor="White" />
60+
<Label Text="ping :" TextColor="White" />
6161
<Label Text="{Binding Ping}" TextColor="White" />
62-
<Label Text="ports : " TextColor="White" />
62+
<Label Text="ports :" TextColor="White" />
6363
<Label Text="{Binding Ports}" TextColor="White" />
6464

6565
</StackLayout>

0 commit comments

Comments
 (0)