Код: Выделить всё
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;
Код: Выделить всё
/data/user/0/com.ivsoftware.demo.maui.onepage/files/settings.db
Код: Выделить всё
C:\Users\tgreg\AppData\Local\settings.db
Код: Выделить всё
C:\Users\tgreg\AppData\Local\Packages\com.ivsoftware.demo.maui.onepage_9zz4h110yvjzm\LocalCache\Local\settings.db
В сценарии отладки WinForms ( например) этот же код ДЕЙСТВИТЕЛЬНО создаст файл здесь:
Код: Выделить всё
C:\Users\tgreg\AppData\Local\settings.db
Код: Выделить всё
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;
Подробнее здесь: https://stackoverflow.com/questions/793 ... ndows-mach