Arrays start indexing from 0 and the GetDirectories() method returns the actual number of directories (remember we count things from 1 not 0 ) .

a simple example in C# might clear things up :
Code:
System.IO.DirectoryInfo dirInfo=new System.IO.DirectoryInfo("path");

			//GetDirectories = 12
			for (int i=0;i<dirInfo.GetDirectories().Length;i++)
			{
				//Here max value for i is 12 but executes 11 times
			}

			for (int i=0;i <=dirInfo.GetDirectories().Length-1;i++)
			{
				//Here max value for i is 11 and executes 11 times
			}