AppDomain.CurrentDomain.GetData ("DataDirectory") always returns Null

In my program, I need to copy the template database from the default location, which, as I understand it, will differ depending on the installer used. The problem is that I cannot read the actual path | DataDirectory | I understand that I have to use AppDomain.CurrentDomain.GetData ("DataDirectory"), but it always returns Null in the debugger, which means that I cannot verify my code. I tried the following two syntaxes:

string sourcePath = AppDomain.CurrentDomain.GetData("DataDirectory").ToString(); 

and

 string defaultpath = Convert.ToString(AppDomain.CurrentDomain.GetData("DataDirectory")); 

Am I doing something wrong?

Thanx!

+4
source share
1 answer

Try using APPBASE

 AppDomain.CurrentDomain.GetData("APPBASE") 

http://msdn.microsoft.com/en-us/library/system.appdomainsetup.applicationbase.aspx

If you want the DataDirectory key, you must execute before SetData

+8
source

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


All Articles