0

I see some connection string like this:

connectionString="Data Source=(localdb)\v11.0;AttachDbFilename=|DataDirectory|\DataAccessExamples.mdf;Integrated Security=True"
  • How could I determine where the DataDirectory is?
  • What does the "|" symbol mean?
  • What's the official name of things like DataDirectory? I have seen substitution string or macro? Or anything else?
  • Is there any other things like DataDirectory?
  • Where can I find a complete reference list for them?
smwikipedia
  • 61,609
  • 92
  • 309
  • 482

1 Answers1

0

You can use the following code snippet to see if the DataDirectory value is defined in the current AppDomain:

string dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory") as string;

The DataDirectory data value is essentially a "special" value that refers to a directory that is used to store local data for applications, such as with SQL LocalDB and SQL Compact Edition.

The pipes are just used as special delimiters to distinguish the DataDirectory AppDomain data value from a filesystem directory named DataDirectory.

Various other such values can be found documented on the MSDN page for the method.

Martin Costello
  • 9,672
  • 5
  • 60
  • 72