What is the difference between a directory and a folder?


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:

Folders

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

Update: The Web server “helpfully” closed some tags prematurely. Apparently it doesn’t want you to nest tables. Replaced nested table with DIV.

Comments (37)
  1. dave says:

    For some odd reason, it is not generally appreciated that Explorer is not actually a file-system browser.  Thus you sometimes see complaints that Explorer 'hides' things from the user (this is usually accompanied by whining about how the computer belongs to the user and not to 'Micro$oft' and how dare they etc. etc.)

    I usually respond by asking whether they'd find it useful to see the contents of $Recycle.bin* displayed as $R7PCNNN.txt, etc.

  2. Vilx- says:

    Tangential question: is it possible to extend the built-in unzipper to allow other archive formats – say, RAR and 7z?

  3. Brian Frost says:

    Since you raise the subject of displaying zip file contents, although this might be regarded as a virtual file operation it does actually unzip files into a temporary folder to perform its action. Sincve this might be a security issue, at what point are these files removed?

    [When you close the last ZIP folder. -Raymond]
  4. RobertWrayUK says:

    @Vilx, It might be more appropriate to say "is it possible to extent the shell to allow other archive formats", as the built-in unzipper is a shell extension currently provided by zipfldr.dll. Writing a shell extension to handle .RAR, for example, is entirely possible.

  5. Andreas Rejbrand says:

    That is an incorrect Euler diagram.

  6. Daniel says:

    @Andreas, @Raymond: looking at the source code of the post, I'm guessing Raymond had the correct intentions, but accidentally closed the inner table before placing "Directories" inside it, probably wrangling with some poor WYSIWIG tool.

    [The Web server is rewriting my HTML as I upload it! Need to figure out how to tell it "Hands off!" -Raymond]
  7. Anthony Frazier says:

    @Robert: Not only is it possible, it's long since been done.  The apparently dead/abandoned ICEOWS Project (http://www.iceows.com/) allowed for exactly this.  It let the user turn a wide variety of archive files into virtual folders that could be browsed in Explorer.  I forget exactly what trick it used to differentiate the two — I think it created a directory with the same name as the archive file and put the archive file into the directory by itself.  Maybe with a bit of metadata to notify the shell extension of what it needed to do.

  8. Adam Rosenfield says:

    @Brian Frost: It shouldn't need to unzip the files until you actually request the file contents (such as by double-clicking a file in the archive or by copying it into the real file system).  Until then, it can just load the archive headers into memory to get the directory structure and the names and sizes of all of the files.

    When you do request the file contents, it does appear to unzip the files to a temporary directory.  On Windows 7, double-clicking a file in a ZIP archive in explorer causes it to extract the file to %TEMP%/ziparchivename.zip/filename, and then it launches the associated program on that file (I found this out using Process Monitor).  It does not appear to delete that temporary file.

    I don't really see this as a security issue, since your %TEMP% directory is only accessible to you and administrators, and I believe that it gets cleaned out on reboot.  It could potentially use up a lot of disk space, but no more space than if you had just fully extracted the archive yourself.

    [The temporary files are removed when you close the last ZIP window. Of course, if you do that before exiting the application that opened the temporary file, the cleanup will fail… -Raymond]
  9. Alex Grigoriev says:

    @Vilx-:

    Unwanted answer to a tangential question: I wish people stop sending RAR, Zipx or (God forbid) ARJ. I don't want to install Winrar or Winzip to deal with that.

  10. Anthony Frazier says:

    @Adam Rosenfield: %TEMP% doesn't get cleaned out on reboot by default.  It's possible that the shell is adding extracted files to the Pending File Rename Operations list though.

  11. Kyle says:

    @Alex

    I've found that 7-Zip, while not pretty, gets the job done without any nag screens.

  12. CarlD says:

    @Alex G – ARJ? OMG.  Seriously though, I infrequently have to resort to RAR to get around some client's annoying email filter that knows about ZIP (and re-named ZIP) but has no clue what to do with a RAR file.

    @Kyle – Agreed! 7-Zip rules.

  13. Troll says:

    And what is the difference between "File Folder" and "Folder" as Windows XP's File Types tab shows (and the evil NT 6'x hides)?

    @Vilx, Microsoft has released namespace extension for LZH format for the Japanese version of Windows as it is popular there. The Japanese version of Windows 7 also ships with the LZH folder built-in. Some guy also tried a 7-Zip namespace extension (http://7zipshell.codeplex.com/)!!!!!! If anyone can get it to work…

  14. RichB says:

    Duplicate of blogs.msdn.com/…/4179107.aspx

    [Not an exact duplicate, but closely-related. That article is about progids. This article is about end-user terminology. By an amazing coincidence, they match! -Raymond]
  15. Troll says:

    @Anthony Frazie, thanks! I discovered ICEOWS right now. One of the benefits of reading a shell-related blog. Does it work with Windows Vista/7 32-bit?

  16. Troll says:

    No it doesn't work. As with 80% shell extensions, XP is the end of the road.

  17. Adam Rosenfield says:

    [The temporary files are removed when you close the last ZIP window. Of course, if you do that before exiting the application that opened the temporary file, the cleanup will fail… -Raymond]

    Ah, good point, I hadn't bothered to close the Explorer window I was using with my quick test.  The cleanup will only fail if the program keeps a file handle open.  Some well-behaved programs like Notepad do not keep a file handle open (that's not to say that programs which keep a handle are not well-behaved: they could have very good reasons for doing so.  But it's much more convenient in many cases when the program closes the handle).

  18. GregM says:

    Adam, even well-behaved programs like notepad can presumably make this fail by having their current directory set to the temporary directory (or a subdirectory of it).

    blogs.msdn.com/…/10087919.aspx

  19. Adam Rosenfield says:

    @GregM: Yes, that's certainly possible, though in this case Notepad is launched with C:WindowsSystem32 as its current directory.

  20. Vilx- says:

    @Alex – indeed, crappy mailservers which forbid executables of every kind (including in zipped files) are the reason why I too regularly have to resort to some more exotic archive format. Being a developer, I have to send such files quite often. Actually, the default Outlook configuration also prevents saving DLL attachments – although I don't know right now if it also scans ZIP files.

  21. Miral says:

    I recall some fun ensuing from a certain library's habit of producing Zip64 archives coupled with XP's lack of support for those archives (which was fixed in Vista).

    7-zip and WinRAR are both decent archivers; WinRAR has the better UX of the two, at least the last time I checked.  Avoid WinZip like the plague, though.  (It has an all-folders-are-one-folder mentality coupled with UX difficulty in updating just a few files in an existing archive.)

  22. Random832 says:

    Not all directories are folders, either, in a sense: Some directories, even if you open them by path, won't give you a "File Folder" [i.e. progid "Directory"] view, but instead of whatever virtual folder they are the backing store of. Temporary Internet Files, Fonts, the GAC, and (in Vista/7 at least) the user recycle bin directory (C:$Recycle.Bin[USER SID]) all do this.

    It's weird that the desktop directory has never done this, now that I think about it. Maybe it's so you can clearly see the distinction between the user desktop and the all users desktop

  23. Joseph Koss says:

    I avoid RAR files like the plague. The "warez-kiddies" love the format (its notably better than ZIP at the act of compression, after all) leading to a good portion of the ones on the internet containing payloads that target the warez-kiddies for their inclusion into a botnet and so forth, as well as nefarious folk sticking key loggers and whatnot into those pirated warez and offering them up.

    Additionally, RAR isnt even close to offering the best compression out there so given the choice its not something I would use. I use ZIP for universal compatibility and easy of use, and I would use WINRK (a good trade-off between the best compression and compression speed, just a few percent worse than the best of the best PAQ series of archivers)

    So when I say that I avoid them like the plague, I really mean that I am trying to avoid getting the plague by avoiding those files. Luckily I dont have people emailing me ones that I am expected to trust, so I don't even have the ability to decompress them.

  24. Worf says:

    I like the Winzip like list-all-files view – the RAR style gets annoying when you need to traverse through comples trees to extract a few files. Or just trying to see if the file looks complete and what you compressed is a complex deep tree.

    I tend to use TugZip as my archive program – it offers both views and supports a ton of formats. Needs unrar.exe and unace.exe if you want to support those formats, but it's free.

    As for emailing zips of exes, I've usually renamed from .zip to .zio or something.

  25. Burak KALAYCI says:

    I prefer WinZip like list-all-files view for smaller archives. When the archive has more than 1000 files, or, when there are many files with the same name differentiated by the directory they are in, RAR style is more convenient.

    But the thing that bothers me with RAR style view is that, it applies to the file system too. I mean, if it were restricted to the compressed file, that would be totally fine. But you can go up a directory, even at the root of the archive, and suddenly you are seeing regular files: you have exited the archive! At this point, RAR style view becomes a shell/explorer view, I never asked for.

  26. GWO says:

    So how does Windows decide what you want when you type a Folder name into the explorer address bar?  If you type "Control Panel" you get the Control Panel.  If you type "Control PanelMail" you get the Mail Control Panel.  If you type Desktop, you get the Desktop.  If you type Desktopfilename.jpg (where filename.jpg is a file on your Desktop), you get … well, you don't get what you expect, even though Explorer AutoComplete has handily saved you typing the whole name.

  27. Larry Hosken says:

    W-wait.  It was easier to get a layout working with divs than with tables?!? The web doesn't make sense to me anymore.

    Hmm, maybe I should register the giveupandusedivs.com domain.

  28. GregM says:

    I think we're going way off topic here, but WinZip has had an explorer style view for years.

  29. Burak KALAYCI says:

    Just to make my comment more clear, the version of WinZip I use and know of is 8.1, from 2001 according to the about box. I didn't need to fix it as it wasn't broken, until about a year ago, when I switched to 7-zip for my main archiver, but I still keep WinZip (8.1) around.

  30. Cheong says:

    @Vilx: I think a lot of email filters allow compressed files to pass through if they have .TXT extension even if it's a compression format it knows. Perheps you can try that, and include instruction in mail body for which kind of extension it's to be changed to.

  31. Cheong says:

    @Joseph Koss: Why? RARLab offers free DLL for RAR extraction. Just use any of the archiver like 7-Zip that uses them to unpack it.

  32. Cheong says:

    Because way too many RAR files have malware in them. Didn't I make that clear?

  33. Robert says:

    <Off-topic> All those complaining about WinRAR's folder view as compared to WinZIP's list-all-files view, have you ever thought about looking at the former's menu options and maybe pressing Ctrl+H? WinRAR/7-zip both provide me with a good trade-off between compression levels and (de)compression speed (although WinRAR's UI is certainly better). Sure I could use a PAQ variant or DECOMP8, but I have far better things to do than bog down my fairly decent PC during both compression and decompression, as well as expect others to dedicate similar resources and use such esoteric programs that require them to dabble in the arcane arts of the command-line, just to save a few bytes. As for WinRK, any program whose site "strongly recommends" people to disable UAC (User *Access* Control) before installation (and presumably never turn it back on), specifically run the installer as administrator and run the program in compatibility mode for XP SP3, is one I can live well without, thank you. </Off-topic>

    Raymond – "These other types of folders represent objects in the shell namespace which do not correspond to files." This is the really important bit, methinks! I had this weird exchange on a forum where I kept asking someone to put two files in the same directory, and he kept responding that he had one in the top-level folder and the other in a sub-folder. I just couldn't figure out why the heck he couldn't follow my simple instructions, until it suddenly dawned on me to use "folder" instead of "directory". Believe it or not, instead of thanking me for finally solving his long-standing issue, he started ranting and raving and posting links to dictionary sites, stating that "directory" and "folder" are two different words (duh). That was the essence of his argument. If he'd even remotely mentioned virtual folders and the like, I might have conceded the point, but I come from the DOS world and for better or worse, anything that holds files in it is a directory to me. Glad to know I'm not completely off the mark! :)

  34. Burak KALAYCI says:

    <Off-topic>

    UAC is one of the main reasons Vista sucks. It didn't get the recognition it deserves because Vista sucks on so many levels and UAC, thank FSM, can be shut off. Any program whose site defends UAC, and broken folder virtualization in Vista and W7, I can live well without. Thank you.

    My main complaint with RAR view is that it doesn't respect the 'archive' boundaries. (An archive app should not allow going up a level from the root of the open archive).

    </Off-topic>

    [Why do people post stuff knowing that it's off-topic? (I'm just going to wait a few days and then delete all the off-topic comments.) -Raymond]
  35. Burak KALAYCI says:

    I think Robert used the <Off-topic> tags to imply that he thinks conversation related to WinZip vs. WinRar view is off-topic. (Only one other commenter implied the discussion was off-topic – which I don't agree).

    So IMO Robert was "subtly" criticising other commenters for posting off-topic -at least for not including such tags-, including me, which disturbed me not because I thought I posted something off-topic but because he mentioned the evil UAC – which was way off-topic BTW.

    My <Off-topic> tags were sarcastic. I thought this was obvious. (And it is most probably obvious to Raymond, I guess he just wanted to give me a chance to explain myself to those this is not obvious).

  36. Troll says:

    So what is the difference between "File Folder" and "Folder"?

  37. Henke37 says:

    A file folder contains files and folders, no other kinds of shell objects. But it does not have to correspond to <i>one</i> file system location.

Comments are closed.