2017-11-07 9 views
0

を使用して、新しいSQLiteのファイルを作成します。ディレクトリに存在しない場合、このライブラリを使用してSQLiteファイルを作成する方法を知っています。これに関する文書はなく、ユーザーのマイドキュメントフォルダにファイルを作成したいと考えています。ここまでは私のコードです。C#が、私は私のプロジェクトのためにSQLiteのための最善のORMを探していると私は<a href="https://github.com/praeclarum/sqlite-net" rel="nofollow noreferrer">praeclarum/sqlite-net package</a></p> <p>私にはない問題を発見したpraeclarum/sqliteのネットパッケージ(SQLiteのネットPCL)

private string databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "AttorneySpace\\database.db"); 
private SQLiteConnection db; 

public SQLiteDb() 
{ 
    if (!Directory.Exists(databasePath)) 
    { 
     Directory.CreateDirectory(databasePath); 
    } 
    db = new SQLiteConnection(databasePath); 
    db.CreateTable<Stock>(); 
    db.CreateTable<Valuation>(); 
} 

これは例外です。

An exception of type 'SQLite.SQLiteException' occurred in SQLite-net.dll but was not handled in user code 
Could not open database file: ...AttorneySpace\database.db (CannotOpen) 

答えて

0

私が使用しているライブラリの一部ではありませんが、System.Data.SQLite.SQLiteConnectionでファイルを作成できました。

System.Data.SQLite.SQLiteConnection.CreateFile(databasePath); 
関連する問題

 関連する問題