.net - 与 |Pipe-delimited| 有什么关系?连接字符串中的变量?

标签 .net ado.net syntax macros connection-string

我知道 |DataDirectory| 将在 ASP.NET 应用程序中解析为 App_Data 但它是硬编码的还是有通用机制在起作用%环境变量%

最佳答案

来自 MSDN Smart Client Data Blog:

In this version, the .NET runtime added support for what we call the DataDirectory macro. This allows Visual Studio to put a special variable in the connection string that will be expanded at run-time...

By default, the |DataDirectory| variable will be expanded as follow:

  • For applications placed in a directory on the user machine, this will be the app's (.exe) folder.
  • For apps running under ClickOnce, this will be a special data folder created by ClickOnce
  • For Web apps, this will be the App_Data folder

Under the hood, the value for |DataDirectory| simply comes from a property on the app domain. It is possible to change that value and override the default behavior by doing this:

AppDomain.CurrentDomain.SetData("DataDirectory", newpath)

关于.net - 与 |Pipe-delimited| 有什么关系?连接字符串中的变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14241/

相关文章:

c# - 使用通过 DI 容器注入(inject)的抽象工厂

c# - .NET 中的异常错误代码

c# - Dapper 提供者依赖参数 token

java - 在 Java 中,HashSet<Integer> = new HashSet(2) 和 HashSet<Integer> = new HashSet<Integer>(2) 之间有什么区别?

c++ - 需要一些帮助解决两个错误 (C++)

c# - 为什么 if 条件不检查空值

c# - TabPage.Hide() 是做什么的?

c# - 使用 ADO.NET 一次性执行一堆命令

.net - 禁用 sp_reset_connection

python - Python 正则表达式中的 "(?&lt;!…)"符号是什么意思?