在哪里| DataDirectory目录|界定? [英] Where is |DataDirectory| defined?

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

问题描述

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

遍布SO和互联网的问题和答案吨,但我找不到任何给出了一个答案,这个具体的问题。

所有这些都是默认的,但我无法找到文件本身,

它不存在

在哪里/ 如何获取| DataDirectory目录| 确定

在哪里文件保存,它甚至还存在?如果没有,这是怎么回事?

修改:文件的不是位于 AppDomain.CurrentDomain.GetData(DataDirectory目录)的ToString(); 所有(sqattered)的答案告诉我是应该的。它必须是某处的调试器中断唠叨模型不平等表时我改变模型。它的不可以那里。


解决方案

| DataDirectory目录| 不是文件本身。从这个而老MSDN文章(A报价阅读全文详细信息):


  

在默认情况下,在 | DataDirectory目录| 变量将扩大如下:


  
  

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

  •   
  • 有关的ClickOnce下运行的应用程序,这将是的ClickOnce创建一个特殊的数据文件夹

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

  •   

  
  

引擎盖下的值 | DataDirectory目录| 只是来自于应用程序域的属性。它可以改变值,并通过这样覆盖缺省行为:

  AppDomain.CurrentDomain.SetData(DataDirectory目录的新路径)


对于您的架构不一致进一步的报价:


  

的事情之一,与本地数据库文件时知道的是,他们是任何其它内容的文件处理。对于桌面项目,这意味着在默认情况下,该数据库文件将每一个项目建成时间复制到输出文件夹(又名仓)。 F5后,这里是它会是什么样子磁盘

  MyProject的\\ Data.mdf MyProject的\\ MyApp.vb MyProject的\\ BIN \\调试\\ Data.mdf MyProject的\\ BIN \\调试\\ MyApp.exe的


  
  

在设计时,MyProject的\\ Data.mdf由数据的工具使用。在运行时,应用程序将在输出文件夹下使用该数据库。作为复制的结果,很多人都有IM pression该应用程序并没有将数据保存到数据库文件。其实,这很简单,因为有涉及的数据文件的两个副本。望着通过数据库资源管理器的模式/数据时同样适用。这些工具在项目中使用,而不是一个在bin文件夹中复制。


This is a follow up question of Where is that file on my system?

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.

All is default but I can't find the file itself,

IT'S NOT THERE.

Where/how gets |DataDirectory| defined?

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

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.

解决方案

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

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)

A further quote regarding your schema inconsistencies:

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.

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

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