How to change location | DataDirectory | in an ASP.NET application embedded in C #

Possible duplicate:
Using relative path in connection string for Access DB in C #

This is my current connection string in web.config

<connectionStrings> <add name="dbConnection" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\GeauxEatAccessDB.accdb"/> </connectionStrings> 

but instead of searching in the App_Data folder, the application looks

 "C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\DevServer\\10.0" 

which is wrong. How and where can I change the default location | DataDirectory | to be the relative path of App_Data inside the project folder?

+4
source share
1 answer

You need to call the AppDomain.SetData method to indicate where | DataDirectory | indicates:

 AppDomain.CurrentDomain.SetData("DataDirectory", "YourPath"); 
+6
source

Source: https://habr.com/ru/post/1443542/


All Articles