1
我正在为C#winforms,sqlite应用程序做一个SETUP项目。 连接字符串似乎有点问题。用户将把他想要的数据库放在一个位置(v会告诉他)。在这个例子中,它是"C:\\Program Files(x86)\\DefaultCompany\\RSetup";
用户可以使用他自己的数据库副本。DataDirectory设置项目
所以我将数据目录设置到Program.cs主目录中的这个路径 这是我能想到的唯一方法。如果有更好的方式,那就是grt !!。
App.config
<add name="ConnString" connectionString="|DataDirectory|\MySQlite.db;Compress=True;Version=3"
providerName="System.Data.Sqlite" />
Program.cs
Setting the datadirectory to the path of the executable. Currently hard coded the path of the executable
static void Main()
{
AppDomain.CurrentDomain.SetData("DataDirectory","C:\\Program Files(x86)\\DefaultCompany\\RSetup");
这似乎没有工作。它不会给出任何错误,除非数据不是空白的。似乎并没有在这两个是工作建立和常规项目
谢谢 JC