views:

1483

answers:

9

Is C drive treated as the root folder in windows when one says \folder1\folder2\ in linux and windows C:\folder1\folder2.

A: 

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"

Muxa
The concept of a "current drive" pertains only to command shells and file dialogs etc, not to the system as a whole.
bzlm
Sorry you are wrong, AFAIK each process has its own current path.
Sklivvz
+9  A: 

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.

Gerald
+2  A: 

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.

Chris Charabaruk
C is not invariably the home of the operating system. It usually is, but you can install the operating system on any drive letter. Or you can have multiple operating systems installed on multiple drive letters.
Gerald
Well, almost invariably. I've yet to actually run across a Windows system that isn't homed on the C: partition.
Chris Charabaruk
Either way, the commonality of C being the home drive is irrelevant to the question. "C:\" is still not analogous to "/".
bzlm
And that's stated in my answer. Read it again, particularly THE FIRST SENTENCE, before downvoting me.
Chris Charabaruk
+3  A: 

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).

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.

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.

Each individual drive filesystem does however behave similarly to UNIX, and does have a root called "\".

levik
Well, not *pure* UI sugar, there is the idea of a 'shell namespace', that has things like the user directory, My Computer, Network, Desktop, Recycle Bin and some others under it's root: There's an API and everything!
Simon Buchan
A: 

In windows the root folder would be the desktop. Desktop->Computer->C:\folder1\folder2 with the IShellFolder Interface.

CiNN
The desktop is a virtual folder, and does not actually exist in the file system.
Chris Charabaruk
Chris, you're wrong. The desktop is a "special shell folder", but it exists in the file system. Also, I think the Desktop *is* a good analogous metaphor to the "root folder" in Unix, since it's used the same way by users of the respective systems.
bzlm
No, it's analogous to "~/Desktop" in unix systems.
Sklivvz
@bzlm See what Skilwz said. In fact, not just ~/Desktop but something like /usr/share/Desktop too. The Windows desktop is virtual; other folders (and code) feed into it only. Learn ur Win32.
Chris Charabaruk
+7  A: 

At the filesystem level the Win32 API has no root folder, but as others have pointed out the Shell API does, ie. the Desktop. The Shell namespace is browsed with the (graphical) shell, which happens to be 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 Manager namespace can be browsed with a tool called WinObj.

Hugh Allen
+5  A: 

In windows you do not have a special root node, instead you have some entry point on the filesystem in form of environment variables:

%AppData%

%ProgramFiles%

%CommonProgramFiles%

%SystemDrive%

%SystemRoot%

the better equivalent of a root could be the %SystemDrive%, even if the concept of root is out of context in windows.

Lorenzo Boccaccia
A: 

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". Hugh explains it in more detail.

bzlm
+4  A: 

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.

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:.

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.

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.

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.

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.

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 programmer