嗨,我已经安装了 sqlite-net nuget 包,它带有 2 个 cs 文件:SQLite.cs 和 SQLiteAsync.cs。
SQLite.cs
包含一个名为的类SQLite3
,其中包含方法:
[DllImport("sqlite3", EntryPoint = "sqlite3_win32_set_directory", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern int SetDirectory(uint directoryType, string directoryPath);
我看到SQLiteConnection
构造函数有以下代码:
#if NETFX_CORE
SQLite3.SetDirectory(/*temp directory type*/2, Windows.Storage.ApplicationData.Current.TemporaryFolder.Path);
#endif
但是为什么?!这是做什么的,为什么每次创建新的 SQLiteConnection 时都需要设置它?似乎我AccessViolationExceptions
对这条线有些零星。
更新
我找到了此方法的文档,但仍然不了解 TempDirectory 的用途。那里写的是什么?
/*
** This function sets the data directory or the temporary directory based on
** the provided arguments. The type argument must be 1 in order to set the
** data directory or 2 in order to set the temporary directory. The zValue
** argument is the name of the directory to use. The return value will be
** SQLITE_OK if successful.
*/