login about faq

To prove you're not a spammer, email newuser.lgqa@gmail.com with the subject "Account Request" to request an account.


I wrote some rubbish java code last year that was designed to copy a file, but instead created a folder structure so deep that windows and Linux could not determine the size in order to delete it nor could it be moved or sent to the recycle bin or just deleted via Linux.

An OS re-install was required to get rid of it in the end.

What is the depth to which you can continue you to create folders in windows/mac/linux?

asked Sep 09 '10 at 18:06

SignOff's gravatar image

SignOff
(suspended)

closed Oct 17 '10 at 09:31

The question has been closed for the following reason "The question is answered, right answer was accepted" by SignOff Oct 17 '10 at 09:31


Excerpt from Microsoft's Developer's Network (MSDN)

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\<some 256-character="" path="" string=""><nul>" where "<nul>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

Basically, your entire path can only be 260 characters long, including the drive letter, colon, and slashes for the file structure. So, in order to make a deep, but narrow file structure, you could easily get a directory 127 folders deep, if all of the folder's names were only one character long, with no spaces.

260 (total character places) - 3 ( for "C:") = 257/x+1 x = numbers of characters in folder name

My math is weak, so that formula might not be right, but I think you can grasp the idea.

answered Sep 09 '10 at 19:05

djmoore711's gravatar image

djmoore711
2.1k223455

The maximum path length is 32767, according to this MSDN document.

(Oct 17 '10 at 09:57) Seb Seb's gravatar image

It's not actually the depth that you can continue to create folders in, Windows at least, but it's how many characters you take up doing so.

So if you had C:ABCDEFGHetc... you could have a lot of folders, but I believe there is a restriction on the amount of characters a folder structure can contain before telling you you've gone too far.

answered Sep 09 '10 at 18:09

recck's gravatar image

recck
3.2k32252

You're exactly right. I'll explain in an answer below.

(Sep 09 '10 at 18:17) djmoore711 djmoore711's gravatar image

There isn't a set maximum of how many node children there can be with in a parent node. File systems like NTFS use a B+tree and HFS(+) use a B-tree structure to create a hierarchy of nodes ( or files ) within the database of the file system. There is a limit, but the limit is of total overall nodes within the database, not a set limit of how many children a specific node can have, or how long a branch can extend within the tree. An OS or Filesystem can artificially limit it if they so choose however.

The number of nodes, or files, allowed in a filesystem depend on the bitsize of it... an NTFS or HFS+ system is 32bit, which means it supports 2^32-1.. or 4,294,967,295 files. By the way, a file denotes any node, in other words a directory (or folder) is a file itself that simply contains other files.

answered Sep 09 '10 at 18:16

Granit's gravatar image

Granit
6.3k114393

edited Sep 09 '10 at 18:18

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported


Join Us in the Chat Room

Tags:

×2,011
×1,977
×515
×24
×2

Asked: Sep 09 '10 at 18:06

Seen: 1,112 times

Last updated: Oct 17 '10 at 09:57