sqlite データベース用のプリローダー C# プログラムを作成しようとしています。ファイルを作成してから読み取ると、例外が発生します。削除して新しいものを作成すると、例外が発生します。誰かが私が間違っていることを教えてもらえますか?!
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 );
最後の行は、例外がスローされる場所です。
スタックトレース:
c:\Users\Sgt.Waffles\Documents\Visual Studio 2013\Projects\TidesDatabase\Preloader\SqliteNet.cs:line 153 の SQLite.SQLiteConnection の SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks) で。 .ctor(String databasePath, Boolean storeDateTimeAsTicks) in c:\Users\Sgt.Waffles\Documents\Visual Studio 2013\Projects\TidesDatabase\Preloader\SqliteNet.cs:114 行目 Preloader.Program.Main(String[] args) のc:\Users\Sgt.Waffles\Documents\Visual Studio 2013\Projects\TidesDatabase\Preloader\Program.cs:System.AppDomain._nExecuteAssembly(RuntimeAssembly アセンブリ、String[] args) の System.AppDomain.ExecuteAssembly(String) の 40 行目assemblyFile、Evidence assemblySecurity、String[] args) (System.Threading.ThreadHelper の Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly())。System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext、ContextCallback コールバック、オブジェクト状態、Boolean preserveSyncCtx) での ThreadStart_Context(オブジェクト状態) System.Threading.ExecutionContext.Run(ExecutionContext executionContext、ContextCallback コールバック、オブジェクト状態、Boolean preserveSyncCtx) で System. System.Threading.ThreadHelper.ThreadStart() での Threading.ExecutionContext.Run (ExecutionContext 実行コンテキスト、ContextCallback コールバック、オブジェクト状態)System.Threading.ThreadHelper.ThreadStart() での ExecutionContext.Run (ExecutionContext 実行コンテキスト、ContextCallback コールバック、オブジェクト状態)System.Threading.ThreadHelper.ThreadStart() での ExecutionContext.Run (ExecutionContext 実行コンテキスト、ContextCallback コールバック、オブジェクト状態)