@mariano901229 dziękuję ale próbowałem w ten sposób i coś nie bardzo chce to działać.
SQLiteConnection sQLiteConnection = new SQLiteConnection();
SQLiteConnectionStringBuilder sQLiteConnectionStringBuilder = new SQLiteConnectionStringBuilder();
sQLiteConnectionStringBuilder.Version = 3;
sQLiteConnection.ConnectionString = sQLiteConnectionStringBuilder.ToString();
IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
if (isoStore.FileExists("baza.db"))
{
Console.WriteLine("The file already exists!");
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("baza.db", FileMode.Open, isoStore))
{
Console.WriteLine("Database file: " + isoStream.Name);
sQLiteConnectionStringBuilder.DataSource = isoStream.Name;
}
try
{
sQLiteConnection.Open();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Wynik w konsoli:
The file already exists!
Database file: [Nieznana]
'WindowsFormsApplication1.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_pl_b77a5c561934e089\mscorlib.resources.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Exception thrown: 'System.ArgumentException' in System.Data.SQLite.dll
Data Source cannot be empty. Use :memory: to open an in-memory database
The program '[15576] WindowsFormsApplication1.vshost.exe: Managed (v4.0.30319)' has exited with code -1 (0xffffffff).
Jak widać programowi nie "udaje się" odczytać fizycznej lokalizacji pliku.