且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将MS Access DB文件保留在项目文件夹中的位置.

更新时间:2022-03-27 22:31:40

我建​​议您使用以下其中一项:
1.在应用程序文件夹(您的exe文件所在的位置)中:然后可以编写如下:.\mydb
2.在User \ AppData文件夹中.您可以使用Google并找到使用方法.
I would advice you one of the following:
1. In the application folder (where your exe is located): then you can write as follows: .\mydb
2. In the User\AppData folder. You can use google and find how to use it.


我想您可能会创建一个将db放置到目标位置的安装程序.

或者,您也可以使用app.config定义文件所在的路径.

通常,我们将数据库文件放置在相同的文件夹中以具有更好的访问权限.您也可以使用任何路径.只需将其放置在所需的任何位置,然后使用文件路径编辑app.config:

I think you might create one installer that places the db to the target location.

Or you might also use app.config to define the path of the file where it is located.

Generally we place the database file in the same folder as to have better access. You might also use any path. Just place it anywhere where you want and edit app.config with path of the file:

<br />
<appSettingss><br />
<add key="dbPath" Value="C:\x\y\db.mdb">




现在,在您的代码中,将连接字符串中的文件路径替换为
ConfigurationSettings.AppSettings ["dbPath"];

:thumbsup:




Now in your code replace the filepath in the connection string with
ConfigurationSettings.AppSettings ["dbPath"];

:thumbsup: