sqlwpfdatadirectory

My |DataDirectory| points to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE


When I try to put |DataDirectory| into a Connection String it would keep directing to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE for some reason. Any idea what could have altered the directory path, or where could I find the default setting for DataDirectory? App.config doesn't have a "connectionStrings" in it's code either.


Solution

  • I am not sure if you can change it in the App.config, but you can change the DataDirectory path in your c# code. In my case, we do this in the bootstrapper, depending on Debug/Release Configuration. You can set the DataDirectory with this code:

    AppDomain.CurrentDomain.SetData("DataDirectory", dataDirectoryPath);