Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In my program, I need to copy a template database from the default location, which I understand will be different depending on the installer I choose to use. The problem is that I can't seem to read the actual path of |DataDirectory| I understand that I should use AppDomain.CurrentDomain.GetData("DataDirectory") but it always returns Null in debugger which means I can't test my code. I've 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!

like image 496
PAUL DUFRESNE Avatar asked Sep 05 '12 17:09

PAUL DUFRESNE


1 Answers

Try with APPBASE

AppDomain.CurrentDomain.GetData("APPBASE")

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

If you want DataDirectory key you must execute before SetData

like image 185
Aghilas Yakoub Avatar answered Oct 13 '22 16:10

Aghilas Yakoub