| DataDirectory |界定? [英] Where is |DataDirectory| defined?

查看:129
本文介绍了| DataDirectory |界定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的系统上的哪个文件的跟进问题?

在SO和互联网上的一堆问题和答案,但我找不到任何答案给这个具体问题。

Tons of questions and answers all over SO and the internet but I can't find any that gives an answer to this specific question.

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

Where/how gets |DataDirectory| defined?

文件保存在哪里,是否存在?

Where is the file saved, does it even exist? If not, what is going on?

编辑:文件位于 AppDomain.CurrentDomain.GetData(DataDirectory)。ToString(); 所有(sqattered)的答案告诉我应该是。当我更改模型时,它必须在某个地方,因为调试器打破了模型的不匹配。

edit: The file isn't located at AppDomain.CurrentDomain.GetData("DataDirectory").ToString(); all (sqattered) answers tell me it should be. It must be somewhere as the debugger breaks nagging about the model unequals the table when I change the model. It's not there.

推荐答案

| DataDirectory | 不是文件本身。来自此相当老的MSDN文章的引用(阅读完整的文章细节):

The |DataDirectory| isn't a file per se. A quote from this rather old MSDN article (read the full article for details):


默认情况下, | DataDirectory | 变量将被扩展如下:


  • 对于放置在用户计算机上的目录中的应用程序,这将是应用程序的(.exe)文件夹。

  • 对于在ClickOnce下运行的应用程序,这将是ClickOnce创建的特殊数据文件夹

  • 对于Web应用程序,这将是App_Data文件夹

在引擎盖下, | DataDirectory | 的值仅来自应用程序域上的一个属性。可以通过这样做来更改该值并覆盖默认行为:

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)


有关您的模式不一致的进一步报价:

A further quote regarding your schema inconsistencies:


使用本地数据库文件时需要知道的一件事是将它们视为任何其他内容文件。对于桌面项目,这意味着默认情况下,每次构建项目时,数据库文件将被复制到输出文件夹(也称为bin)。在F5之后,这里是磁盘上的样子

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

在设计时,MyProject \Data.mdf由数据工具使用。在运行时,应用程序将使用输出文件夹下的数据库。作为副本的结果,许多人的印象是应用程序没有将数据保存到数据库文件。实际上,这只是因为有两个拷贝的数据文件。通过数据库资源管理器查看模式/数据时也是一样。工具正在使用项目中的副本,而不是bin文件夹中的副本。

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.

这篇关于| DataDirectory |界定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆