gpt4 book ai didi

sql - |DataDirectory| 在哪里定义?

转载 作者:太空狗 更新时间:2023-10-30 01:38:12 25 4
gpt4 key购买 nike

这是 Where is that file on my system? 的后续问题

SO 和互联网上有大量的问题和答案,但我找不到任何可以回答这个特定问题的答案。

一切都是默认的,但我找不到文件本身,

它不在那里

在哪里/如何获取|DataDirectory| 定义

文件保存在哪里,是否存在?如果不是,那是怎么回事?

编辑:文件位于AppDomain.CurrentDomain.GetData("DataDirectory").ToString();所有( sqattered) 答案告诉我它应该是。它必须在某个地方,因为调试器会在我更改模型时打破关于模型不等于表的唠叨。它在那里。

最佳答案

|DataDirectory| 本身不是一个文件。引用一篇相当古老的 MSDN 文章:

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)

关于您的架构不一致的进一步引用:

One of the things to know when working with local database files is that they are treated as any other content files. For desktop projects, it means that by default, the database file will be copied to the output folder (aka bin) each time the project is built. After F5, here's what it would look like on disk

 MyProject\Data.mdf

MyProject\MyApp.vb

MyProject\Bin\Debug\Data.mdf

MyProject\Bin\Debug\MyApp.exe

At design-time, MyProject\Data.mdf is used by the data tools. At run-time, the app will be using the database under the output folder. As a result of the copy, many people have the impression that the app did not save the data to the database file. In fact, this is simply because there are two copies of the data file involved. Same applies when looking at the schema/data through the database explorer. The tools are using the copy in the project, not the one in the bin folder.

关于sql - |DataDirectory| 在哪里定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12187068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com