目录和文件夹有什么区别?

发布于 2024-10-18 08:13:34 字数 244 浏览 3 评论 0原文

大多数人交替使用术语“文件夹”和“目录”。从程序员的角度来看,有区别吗?如果有,区别是什么?它取决于操作系统,还是存在广泛的普遍共识?

在英语 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

恋你朝朝暮暮 2024-10-25 08:13:34

检查 维基百科 上的“文件夹隐喻”部分。它指出:

目录(文件系统概念)与用于表示它的图形用户界面隐喻(文件夹)之间存在差异。例如,Microsoft Windows 使用特殊文件夹的概念来帮助以相当一致的方式向用户呈现计算机的内容,从而使用户不必处理绝对目录路径,绝对目录路径可能因 Windows 版本和不同版本而异。单独安装。 ...

如果指的是文档容器,术语“文件夹”更合适。术语目录是指文档文件和文件夹的结构化列表在计算机上存储的方式。这种区别可能是由于访问目录的方式造成的。在 Unix 系统上,/usr/bin/ 在命令行控制台中查看时通常称为目录,但如果通过图形文件管理器访问,用户有时可能将其称为文件夹。

Check "The folder metaphor" section at Wikipedia. It states:

There is a difference between a directory, which is a file system concept, and the graphical user interface metaphor that is used to represent it (a folder). For example, Microsoft Windows uses the concept of special folders to help present the contents of the computer to the user in a fairly consistent way that frees the user from having to deal with absolute directory paths, which can vary between versions of Windows, and between individual installations. ...

If one is referring to a container of documents, the term folder is more appropriate. The term directory refers to the way a structured list of document files and folders is stored on the computer. The distinction can be due to the way a directory is accessed; on Unix systems, /usr/bin/ is usually referred to as a directory when viewed in a command line console, but if accessed through a graphical file manager, users may sometimes call it a folder.

月寒剑心 2024-10-25 08:13:34

文件夹不一定是磁盘上的物理目录。例如,它可以是 Windows 中的打印机文件夹或控制面板文件夹。

Raymond Chen 解释:

Windows 95引入了Windows资源管理器
以及术语文件夹。
之间有什么关系
文件夹和目录?

有些人认为 Windows 95
将目录重命名为文件夹,但是
实际上远不止这些。

Windows 资源管理器可让您查看
文件夹,它们是
外壳命名空间。目录是一个
文件夹类型,即文件夹
对应于文件系统位置。
还有其他类型的文件夹,例如
作为控制面板或网络
邻居或打印机。这些其他的
文件夹类型代表对象
shell 命名空间不包含
对应文件。在常见用法中,
术语“虚拟文件夹”已是
适用于引用文件夹
不是目录。换句话说,我们
有这个欧拉图:

(虚拟文件夹 = 文件夹 -
目录)

一般来说,操作的代码
shell命名空间应该运行在
文件夹和项目,而不是目录和
文件,以免将自己束缚于
特定的存储介质。为了
例如,代码将自身限制为
文件将无法导航到
Zip 文件,因为 Zip 的内容
文件以 a 的形式公开
虚拟文件夹。

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:

Windows 95 introduced Windows Explorer
and along with it the term folder.
What is the relationship between
folders and directories?

Some people believe that Windows 95
renamed directories to folders, but
it's actually more than that.

Windows Explorer lets you view
folders, which are containers in the
shell namespace. Directories are one
type of folder, namely, folders which
correspond to file system locations.
There are other types of folders, such
as Control Panel or Network
Neighborhood or Printers. These other
types of folders represent objects in
the shell namespace which do not
correspond to files. In common usage,
the term virtual folder has been
applied to refer to folders which are
not directories. In other words, we
have this Euler diagram:

(Virtual folders = Folders −
Directories)

In general, code which manipulates the
shell namespace should operate on
folders and items, not directories and
files, so as not to tie themselves to
a particular storage medium. For
example, code which limits itself to
files won't be able to navigate into a
Zip file, since the contents of a Zip
file are exposed in the form of a
virtual folder.

无人问我粥可暖 2024-10-25 08:13:34
  • 目录是一个文件系统概念。在 GUI 中,目录表示为文件夹
  • 示例 1:Unix 系统,在命令行控制台中查看时,/usr/bin 通常称为目录路径,但如果通过图形文件访问manager,用户有时可能将其称为文件夹。
  • 示例 2:Windows 同时使用目录(在 mkdircd 等命令中)和文件夹(在 GUI 中)。

目录:名称目录类似于电话簿:

电话簿的图像


< strong>文件夹:名称文件夹代表办公室中使用的文件夹的类比:

办公室文件夹的图像


类比:

  • 文件夹就像一个房间。
  • 目录就像一个了解所有房间的酒店老板。

如果您想要特定的文件夹,请使用该目录。如果您想要特定的房间,请询问酒店老板。
来源

  • Directory is a file system concept. In a GUI the directory is represented as a Folder.
  • Example 1: Unix systems, /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.
  • Example 2: Windows uses both Directory (in commands like mkdir, cd) and Folder (in the GUI).

Directory: The name directory represents an analogy to the telephone directory:

Image of a telephone directory


Folder: The name folder represents an analogy to the file folder used in offices:

Image of office folders


Analogy:

  • A Folder is like a room.
  • A Directory is like a hotel keeper who knows all the rooms.

If you want a specific folder, you use the directory. If you want a specific room you ask the hotel keeper.
Source

一刻暧昧 2024-10-25 08:13:34

引用阿尔瓦罗·G·维卡里奥

大多数时候它们是可以互换的术语。目录是自文件系统早期以来就使用的经典术语,而文件夹是一种友好的名称,Windows 用户可能听起来更熟悉。

主要区别在于文件夹是一个逻辑概念,不一定映射到物理目录。目录是文件系统对象。文件夹是一个 GUI 对象。 维基百科是这样解释的

<块引用>

文件夹名称,打个比方
到办公室使用的文件夹,
最初由 Apple Lisa 使用,是
几乎用于所有现代操作
系统的桌面环境。文件夹
通常用图标来描绘
视觉上类似于物理文件
文件夹。

严格来说,有一个
目录之间的区别
是一个文件系统的概念,并且
图形用户界面隐喻
用于表示它(文件夹)。
例如,Microsoft Windows 使用
特殊文件夹的概念有帮助
呈现计算机的内容
以相当一致的方式向用户提供
这使用户不必
处理绝对目录路径,
不同版本之间可能有所不同
窗户、个人之间
安装。

如果指的是一个容器
文档,术语文件夹更多
合适的。术语目录指的是
以结构化列表的方式
存储文档文件和文件夹
在计算机上。它相当于一个
电话簿包含
姓名、号码和地址列表
并且不包含实际的
文档本身。

Quoting Álvaro G. Vicario:

Most of the times they are interchangeable terms. Directory is a classical term used since the early times of file systems while folder is a sort of friendly name which may sound more familiar to Windows users.

The main difference is that a folder is a logical concept that does not necessarily map to a physical directory. A directory is an file system object. A folder is a GUI object. Wikipedia explains it this way:

The name folder, presenting an analogy
to the file folder used in offices,
and used originally by Apple Lisa, is
used in almost all modern operating
systems' desktop environments. Folders
are often depicted with icons which
visually resemble physical file
folders.

Strictly speaking, there is a
difference between a directory which
is a file system concept, and the
graphical user interface metaphor that
is used to represent it (a folder).
For example, Microsoft Windows uses
the concept of special folders to help
present the contents of the computer
to the user in a fairly consistent way
that frees the user from having to
deal with absolute directory paths,
which can vary between versions of
Windows, and between individual
installations.

If one is referring to a container of
documents, the term folder is more
appropriate. The term directory refers
to the way a structured list of
document files and folders is stored
on the computer. It is comparable to a
telephone directory that contains
lists of names, numbers and addresses
and does not contain the actual
documents themselves.

烟花易冷人易散 2024-10-25 08:13:34

以前我不知道这两个英文单词的区别,即使在Windows注册表编辑器中我也能在下找到FolderDirectory两个子键>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 and Directory, under HKEY_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 (aka system directory), like Recycle Bin, and the file system directory, like C:\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, like C:\Windows, but not a virtual folder. So, like @AntonyW said, in Windows, folders = virtual folders + file system directories.

千秋岁 2024-10-25 08:13:34

文件资源管理器(以前称为 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.

红焚 2024-10-25 08:13:34

此网站对此主题有一个简单但非常详细的解释。

总结:

目录

目录相当于物理文件柜的虚拟等价物。换句话说,它是组织数字数据的容器。与只能存储文件的文件夹不同,目录可以存储文件、子目录和其他目录。

文件夹

与目录一样,文件夹是组织数字数据的容器。然而,与目录不同的是,它只能存储文件。目录是一个分层系统,允许在不同级别上组织数据,而文件夹只是将数据组织到一个级别中。

输入图片此处描述

这是差异表:(来源)
输入图片此处描述

This site has a simple but yet very detailed explanation about this subject.

In summary:

Directory

A directory is the virtual equivalent of a physical file cabinet. In other words, it’s a container for organizing digital data. Unlike a folder, which can only store files, a directory can store files, subdirectories, and other directories.

Folder

Like a directory, a folder is a container for organizing digital data. Unlike a directory, however, it can only store files. While a directory is a hierarchical system that allows organizing data on different levels, a folder simply organizes data into one level.

enter image description here

And here's a table of the differences: (source)
enter image description here

天涯沦落人 2024-10-25 08:13:34

您的链接基本上描述了技术基础上的不同之处。大多数时候,人们可以互换使用它们,他们的选择主要取决于他们来自什么环境。

除非您正在为将修改文件的应用程序进行跨平台开发,否则您不需要了解其中的差异。一旦您准备使用几种不同的文件系统类型,您就应该了解它们的差异。

不要指望人们知道何时使用哪个术语。我认为这些术语是可以互换的,因为知道这些差异的人太少了。

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.

菊凝晚露 2024-10-25 08:13:34

文件夹用于对项目进行分组。

目录有索引。它用于查找特定项目。

Folder is for grouping items.

Directory has index. It is for finding specific item.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文