windows Windows中的根文件夹等效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/151860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
root folder equivalent in windows
提问by Lorenzo Boccaccia
Is C drive treated as the root folder in windows when one says \folder1\folder2\ in linux and windows C:\folder1\folder2.
当有人说linux中的\folder1\folder2\和windows C:\folder1\folder2时,C盘是否被视为windows中的根文件夹。
回答by Gerald
In Windows it's relative to what drive your current working directory is at the time. If your current directory is in the C drive then C:\ would be the root. If the current directory is the D drive then D:\ would be the root. There is no absolute root.
在 Windows 中,它与当前工作目录所在的驱动器有关。如果您的当前目录在 C 驱动器中,则 C:\ 将是根目录。如果当前目录是 D 盘,则 D:\ 将是根目录。没有绝对的根。
回答by Hugh Allen
At the filesystem level the Win32 API has no root folder, but as others have pointed out the Shell APIdoes, ie. the Desktop. The Shell namespace is browsed with the (graphical) shell, which happens to be Explorer.exe.
在文件系统级别,Win32 API 没有根文件夹,但正如其他人指出的那样,Shell API确实如此,即。桌面。Shell 命名空间使用(图形)shell 浏览,它恰好是 Explorer.exe。
At a much lower level, the Windows kernel also has a root folder, and the registry and filesystem are subfolders of it. This is relevant if you are writing a device driver. The Object Managernamespace can be browsed with a tool called WinObj.
在低得多的层次上,Windows 内核也有一个根文件夹,注册表和文件系统是它的子文件夹。如果您正在编写设备驱动程序,这很重要。该对象管理器命名空间可以用一个叫做工具来浏览的WinObj。
回答by Windows programmer
If you're running Windows CE then \ is the root directory. This resembles Unix's / root directory. This is the only kind of Windows where you can get a simple answer to your question.
如果您运行的是 Windows CE,则 \ 是根目录。这类似于 Unix 的 / 根目录。这是您可以获得问题的简单答案的唯一一种 Windows。
If you're running Windows NT/2000/XP/2003 then the closest equivalent is the partition containing files NTLDR, NTDETECT.COM, BOOT.INI, and BOOTFONT.BIN. The BIOS and MBR find this partition by finding which drive to start booting, scanning the MBR, and looking for the active partition. Microsoft calls this the system partition. I'm not completely sure how a program can find which partition this was. Anyway, when you find which drive letter this is, say letter L, then you could say that L:\ is the root directory. 99% of the time this will be drive letter C:.
如果您运行的是 Windows NT/2000/XP/2003,那么最接近的分区是包含文件 NTLDR、NTDETECT.COM、BOOT.INI 和 BOOTFONT.BIN 的分区。BIOS 和 MBR 通过查找要启动的驱动器、扫描 MBR 并查找活动分区来找到该分区。Microsoft 将此称为系统分区。我不完全确定程序如何找到这是哪个分区。无论如何,当您找到这是哪个驱动器号时,比如说字母 L,那么您可以说 L:\ 是根目录。99% 的时间这将是驱动器号 C:。
Also if you're running Windows NT/2000/XP/2003 then you also have a partition which contains the Windows system files, such as directory \Windows or others. Microsoft calls this the boot partition. You can get the drive letter from the symbol %SystemDrive% as someone else said. If this is drive letter Q then you can say that Q:\ is the root of the system drive.
此外,如果您运行的是 Windows NT/2000/XP/2003,那么您还有一个包含 Windows 系统文件的分区,例如目录 \Windows 或其他。Microsoft 将其称为引导分区。正如其他人所说,您可以从符号 %SystemDrive% 中获取驱动器号。如果这是驱动器号 Q,那么您可以说 Q:\ 是系统驱动器的根目录。
If you're running Vista then things are more complicated. If you installed by booting the DVD, then the boot partition (containing the system files) is C: and your system partition (containing the boot files) is D:, unless they're the same partition and then the partition is C:. But if you installed by having Windows running already, inserting the DVD and starting the installer under that Windows installation, then the drive letters could be almost anything.
如果您运行的是 Vista,那么事情会更加复杂。如果通过引导 DVD 安装,则引导分区(包含系统文件)是 C:,而您的系统分区(包含引导文件)是 D:,除非它们是同一个分区,然后分区是 C:。但是,如果您通过运行 Windows 进行安装,插入 DVD 并在该 Windows 安装下启动安装程序,那么驱动器号几乎可以是任何东西。
In Windows 95/98/ME the BIOS and MBR would look for files IO.SYS, COMMAND.COM, and some others, in the active partition. This would usually get drive letter C: so the root partition would be C:. As always, the Windows system files could be installed in directory \Windows or others on any partition.
在 Windows 95/98/ME 中,BIOS 和 MBR 会在活动分区中查找文件 IO.SYS、COMMAND.COM 和其他一些文件。这通常会得到驱动器号 C:,所以根分区将是 C:。与往常一样,Windows 系统文件可以安装在目录 \Windows 或任何分区的其他目录中。
Some people talk about a desktop. Well sure, each logged in user has a desktop. This is somewhat like each Unix user's home directory. It sure isn't a root directory.
有些人谈论桌面。当然,每个登录用户都有一个桌面。这有点像每个 Unix 用户的主目录。它肯定不是根目录。
Addendum: In the second-to-last paragraph, about Windows 95/98/ME, I typed "so the root partition would be C:." That is, letter C, a colon, a backslash, and then a period for the end of the sentence (not part of the directory name). When viewing the page, the backslash isn't showing. But when editing this answer to add this addendum, the backslash is there exactly as it should be, exactly as I typed it.
附录:在倒数第二段中,关于 Windows 95/98/ME,我输入了“所以根分区将是 C:”。即,字母 C、一个冒号、一个反斜杠,然后是句末的句点(不是目录名称的一部分)。查看页面时,反斜杠未显示。但是,在编辑此答案以添加此附录时,反斜杠与我输入的完全一样。
回答by Lorenzo Boccaccia
In windows you do not have a special root node, instead you have some entry point on the filesystem in form of environment variables:
在 Windows 中,您没有特殊的根节点,而是以环境变量的形式在文件系统上有一些入口点:
%AppData%
%应用程序数据%
%ProgramFiles%
%程序文件%
%CommonProgramFiles%
%CommonProgramFiles%
%SystemDrive%
%系统驱动器%
%SystemRoot%
%SystemRoot%
the better equivalent of a root could be the %SystemDrive%, even if the concept of root is out of context in windows.
更好的 root 等效项可能是 %SystemDrive%,即使 root 的概念在 Windows 中是脱离上下文的。
回答by Chris Charabaruk
Windows doesn't share the UNIX concept of a root folder. Instead, each partition or device with file storage has its own root folder. Given that the C: partition/drive is (almost) invariably the home of the operating system, however, you may consider its root folder to be the same for Windows.
Windows 不共享根文件夹的 UNIX 概念。相反,每个带有文件存储的分区或设备都有自己的根文件夹。鉴于 C: 分区/驱动器(几乎)总是操作系统的主目录,但是,您可能认为它的根文件夹与 Windows 相同。
回答by levik
As others have mentioned Windows is unlike UNIX where the file systems have a single logical "path" space for all the devices (each device mounts into this space, such as at /dev/floppy).
正如其他人所提到的,Windows 与 UNIX 不同,UNIX 的文件系统有一个用于所有设备的逻辑“路径”空间(每个设备都安装到这个空间中,例如 /dev/floppy)。
In Windows, each device (be it a Hard Disk partition, a CD/DVD Rom or a flash drive) has its own logical path space, rooted at the "\" directory of its logical drive letter.
在 Windows 中,每个设备(无论是硬盘分区、CD/DVD Rom 还是闪存驱动器)都有自己的逻辑路径空间,其根目录是其逻辑驱动器号的“\”目录。
While Windows Explorer does a half-decent job of organizing all the drives under "My Computer", this is pure UI sugar, and there's no way to get from one drive letter to another via relative paths.
虽然 Windows 资源管理器在组织“我的电脑”下的所有驱动器方面做得不错,但这是纯粹的 UI 糖,并且无法通过相对路径从一个驱动器号到另一个驱动器号。
Each individual drive filesystem does however behave similarly to UNIX, and does have a root called "\".
然而,每个单独的驱动器文件系统的行为与 UNIX 相似,并且确实有一个名为“\”的根。
回答by CiNN
In windows the root folder would be the desktop. Desktop->Computer->C:\folder1\folder2 with the IShellFolder Interface.
在 Windows 中,根文件夹将是桌面。桌面->计算机->C:\folder1\folder2 带有 IShellFolder 接口。
回答by bzlm
Unix uses the file system to represent almost all parts of the system, from top to bottom, which means the root file system folder logically also represents the "system root". But in Windows, the file system is not tied to the system so intimately, so within the file system there is no concept of a "system root". Hughexplains it in more detail.
Unix 使用文件系统来代表系统的几乎所有部分,从上到下,这意味着根文件系统文件夹在逻辑上也代表“系统根”。但是在 Windows 中,文件系统与系统的联系并不那么紧密,因此在文件系统中没有“系统根”的概念。休更详细地解释了它。
回答by Muxa
yes, "\" is the root folder of the current drive. E.g. DOS command "cd \" changes current directory to the root folder, or "cd \folder1\folder2" goes to "c:\folder1\folder2"
是的,“\”是当前驱动器的根文件夹。例如,DOS 命令“cd \”将当前目录更改为根文件夹,或者“cd \folder1\folder2”转到“c:\folder1\folder2”
回答by genius
As a matter of fact, windows has a root folder. The folder, though not visible, is known as 'i386'
事实上,windows 有一个根文件夹。该文件夹虽然不可见,但被称为“i386”