Code: Select all
protected virtual string DatabasePath
{
get
{
if (_databasePath is null)
{
var platformDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Directory.CreateDirectory(platformDirectory);
_databasePath = Path.Combine(platformDirectory, "settings.db");
using (var cnx = new SQLiteConnection(DatabasePath))
{
cnx.CreateTable();
cnx.CreateTable();
}
Debug.WriteLine($"250106.A: {DatabasePath}");
bool openLocation = false;
{ } // [WINDOWS] As a debugging convenience, set openLocation to true to open directory in FileExplorer.
if (openLocation)
{
Process.Start(new ProcessStartInfo
{
UseShellExecute = true,
FileName = platformDirectory
});
}
}
return _databasePath;
}
}
string? _databasePath = null;
Code: Select all
/data/user/0/com.ivsoftware.demo.maui.onepage/files/settings.db
Code: Select all
C:\Users\tgreg\AppData\Local\settings.db
Code: Select all
C:\Users\tgreg\AppData\Local\Packages\com.ivsoftware.demo.maui.onepage_9zz4h110yvjzm\LocalCache\Local\settings.db
In einem WinForms-Debug-Szenario ( (zum Beispiel) wird derselbe Code WIRKLICH hier eine Datei erstellen:
Code: Select all
C:\Users\tgreg\AppData\Local\settings.db
Code: Select all
protected virtual string DatabasePath
{
get
{
if (_databasePath is null)
{
bool needQualify = ??? /* DETERMINED BY INSPECTING EFFECTIVE PATH. */;
var platformDirectory = needQualify
? Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"IVSoftware",
Assembly.GetEntryAssembly()?.GetName().Name ?? "Unknown")
: Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Directory.CreateDirectory(platformDirectory);
.
.
.
}
}
}
string? _databasePath = null;