What is the difference between a directory and a folder?
What is the difference between a directory and a folder?
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 at least suggests that there is a difference.
回答1
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.
回答2
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.
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.
回答3
- 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 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:
Folder: The name folder represents an analogy to the file folder used in offices:
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
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2017-02-09 System.Drawing.Drawing2D.LinearGradientBrush
2015-02-09 关于EventWaitHandle的Reset