My DatabaseContext has:
string physicalPath = "Filename=" + Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), "Data"), "Database.db");
optionsBuilder.UseSqlite(physicalPath);
My Startup has:
using (var client = new DatabaseContext())
{
client.Database.EnsureCreated();
}
It works perfectly with "D:\\Database.db" but that's not very portable so I need to use its own directories.
Has anyone any idea?
Update: I tried again with a tutorial here and got same error in an exception page.
"An unhandled exception occurred while processing the request. SqliteException: SQLite Error 14: 'unable to open database file'. Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(int rc, sqlite3 db)"
Update: I get "System.UnauthorizedAccessException: 'Access to the path 'C:\Program Files\IIS Express\test.txt' is denied.'" when I try
string path = Path.Combine(Directory.GetCurrentDirectory(), "test.txt");
using (FileStream fs = File.Create(path)) { Byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file."); // Add some information to the file. fs.Write(info, 0, info.Length); }