为什么DataDirectory在运行时不更改 [英] Why doesn't DataDirectory change on run time
问题描述
我正在尝试使用w winform c#应用程序连接到本地数据库
当我将连接字符串设置为数据时:Source=C:\Users\PACKARD BELL\documents\visual studio 2010\Projects\GestionStock\MyApp\Mydb.sdf
它工作正常,但当我将其设置为Data Source=|DataDirectory|\Mydb.sdf
时,它不起作用
我尝试在控制台中打印带有数据目录变量的连接字符串,但发现它没有变化
I am tring to connect to a local database with w winform c# application
when i set my connection string to Data: Source=C:\Users\PACKARD BELL\documents\visual studio 2010\Projects\GestionStock\MyApp\Mydb.sdf
it works fine but when i set it to Data Source=|DataDirectory|\Mydb.sdf
it dosen't work
i tried to print the connection string with the data directory variable in the console and i found that it dosen't change
我希望连接字符串随应用程序文件夹的位置而改变
i want the connection string to change with the location of the application folder
我该怎么做? 预先感谢
How can i do that? thanks in advance