我知道 |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/