目录和文件夹有什么区别?
大多数人交替使用术语“文件夹”和“目录”。从程序员的角度来看,有区别吗?如果有,区别是什么?它取决于操作系统,还是存在广泛的普遍共识?
此在英语 UI 术语下的贡献:目录还是文件夹?< /em> 至少表明存在差异。
Most people use the terms "folder" and "directory" interchangeably. From a programmer point of view, is there a difference, and if so, what is it? Does it depend on the OS, or is there a broad, general consensus?
This contribution under English UI Terminology: Directory, or Folder? at least suggests that there is a difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
检查 维基百科 上的“文件夹隐喻”部分。它指出:
Check "The folder metaphor" section at Wikipedia. It states:
文件夹不一定是磁盘上的物理目录。例如,它可以是 Windows 中的打印机文件夹或控制面板文件夹。
Raymond Chen 解释:
A folder is not necessarily a physical directory on a disk. It can be, for example, the printers folder or control panel folder in Windows.
Raymond Chen explains:
/usr/bin
通常称为目录路径,但如果通过图形文件访问manager,用户有时可能将其称为文件夹。mkdir
、cd
等命令中)和文件夹(在 GUI 中)。目录:名称目录类似于电话簿:
< strong>文件夹:名称文件夹代表办公室中使用的文件夹的类比:
类比:
如果您想要特定的文件夹,请使用该目录。如果您想要特定的房间,请询问酒店老板。
来源
/usr/bin
is usually referred to as a directory path when viewed in a command line console, but if accessed through a graphical file manager, users may sometimes call it a folder.mkdir
,cd
) and Folder (in the GUI).Directory: The name directory represents an analogy to the telephone directory:
Folder: The name folder represents an analogy to the file folder used in offices:
Analogy:
If you want a specific folder, you use the directory. If you want a specific room you ask the hotel keeper.
Source
引用阿尔瓦罗·G·维卡里奥:
Quoting Álvaro G. Vicario:
以前我不知道这两个英文单词的区别,即使在Windows注册表编辑器中我也能在
下找到
。Folder
和Directory
两个子键>HKEY_CLASSES_ROOT直到我在注册表中手动创建一些值并观察上下文菜单项的差异后,我才知道其中的差异。如果我仅在
HKEY_CLASSES_ROOT\Folder\shell
下创建一个节点,我发现它出现在两个虚拟文件夹(又名系统目录
)的上下文菜单中,如回收站
,以及文件系统目录,例如C:\Windows
。如果我只在
HKEY_CLASSES_ROOT\Directory\shell
下创建一个节点,它只会出现在文件系统目录的上下文菜单中,如C:\Windows
,但不会出现在虚拟目录中文件夹。所以,就像@AntonyW所说,在Windows中,文件夹=虚拟文件夹+文件系统目录。I didn't know the difference between these two words in English before, even in the Windows registry editor I could found two sub-keys,
Folder
andDirectory
, underHKEY_CLASSES_ROOT
.I didn't know the difference until I created some values manually in registry and observed the differences of context menu items. If I create a node under
HKEY_CLASSES_ROOT\Folder\shell
only, I found that it appears in the context menu of both the virtual folders (akasystem directory
), likeRecycle Bin
, and the file system directory, likeC:\Windows
.If I create a node under
HKEY_CLASSES_ROOT\Directory\shell
only, it only appears in the context menu of the file system directory, likeC:\Windows
, but not a virtual folder. So, like @AntonyW said, in Windows, folders = virtual folders + file system directories.文件资源管理器(以前称为 Windows 资源管理器的 GUI)中显示的文件夹名称不一定与其代表的目录相同。考虑这样一种情况,您尝试以编程方式打开特定文件夹,即大容量存储上的普通目录,而不是虚拟存储。假设这是由用户根据文件资源管理器中显示的名称指定的。该名称可能已被目录上的备用数据流 (ADS) 中的信息覆盖,并且您的程序将不会通过其真实路径名引用该文件。
在我遇到的两个示例中,我的应用程序无法打开用户指定的路径名。其中一个示例与 OneDrive 有关;我不记得另一个例子的全部情况。无论如何,显示名称存储在名为 ms-properties:$DATA 的 ADS 中。
您可以使用 CMD.EXE 使用 DIR/R 列出 ADS。使用文件资源管理器中的“属性”菜单项重命名此类文件夹会更改此 ADS 的内容,并且在文件资源管理器中向最终用户显示的名称是他或她键入的名称。但此过程不会重命名该目录。
Names of folders displayed in File Explorer (the GUI formerly called Windows Explorer) are not necessarily the same as the directories they represent. Consider a case where you are trying to programmatically open a particular folder, a plain directory on mass storage, not a virtual store. Say this was specified by a user based on the name displayed in File Explorer. This name could have been overridden by information in an alternate data stream (ADS) on the directory, and your program will not be referring to the file by its true pathname.
In two examples I've encountered, my app could not open a pathname specified by the user. One of these examples was related to OneDrive; I don't remember the full circumstances of the other example. Anyway, the display name is stored in the ADS named ms-properties:$DATA.
You can use CMD.EXE to list the ADS using DIR/R. Renaming such folders using the Properties menu item in File Explorer changes the contents of this ADS, and the name displayed to the end user in File Explorer is what he or she typed. But this procedure does not rename the directory.
此网站对此主题有一个简单但非常详细的解释。
总结:
目录
文件夹
这是差异表:(来源)
This site has a simple but yet very detailed explanation about this subject.
In summary:
Directory
Folder
And here's a table of the differences: (source)
您的链接基本上描述了技术基础上的不同之处。大多数时候,人们可以互换使用它们,他们的选择主要取决于他们来自什么环境。
除非您正在为将修改文件的应用程序进行跨平台开发,否则您不需要了解其中的差异。一旦您准备使用几种不同的文件系统类型,您就应该了解它们的差异。
不要指望人们知道何时使用哪个术语。我认为这些术语是可以互换的,因为知道这些差异的人太少了。
Your link basically describes what is different on a technical basis. Most of the times People use them interchangeably and which they choose is mostly based on what environment they come from.
Unless you are doing development cross-platform for an application that will modify files, you don't need to know the differences. As soon as you are preparing to work with several different file system types, you should know their differences.
Don't expect people to know which term to use when. I think of those terms as interchangable, since the differences are known to too few people.
文件夹用于对项目进行分组。
目录有索引。它用于查找特定项目。
Folder is for grouping items.
Directory has index. It is for finding specific item.