I'm trying to make a preloader C# program for a sqlite database. When I create then read the file, I get exeptions. When I delete and make a ew one, I get exceptions. Can someone please let me know what I'm doing wrong?!
string dbPath = @"..\..\..\TidesDatabase\Assets\Database.3db";
bool exists = File.Exists (dbPath);
if ( exists )
{
File.SetAttributes( dbPath, FileAttributes.Normal );
File.Delete( dbPath );
File.Create( dbPath );
File.SetAttributes( dbPath, FileAttributes.Normal );
}
else
{
File.Create( dbPath );
File.SetAttributes( dbPath, FileAttributes.Normal );
}
var db = new SQLiteConnection( dbPath );
The last line is where the exception is thrown.
Stacktrace:
at SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks) in c:\Users\Sgt.Waffles\Documents\Visual Studio 2013\Projects\TidesDatabase\Preloader\SqliteNet.cs:line 153 at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks) in c:\Users\Sgt.Waffles\Documents\Visual Studio 2013\Projects\TidesDatabase\Preloader\SqliteNet.cs:line 114 at Preloader.Program.Main(String[] args) in c:\Users\Sgt.Waffles\Documents\Visual Studio 2013\Projects\TidesDatabase\Preloader\Program.cs:line 40 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()