public IEnumerable <IDirectory> GetDirectories()
        {
            var meta = this.TryGetMetaData();

            if (meta == null)
            {
                yield break;
            }

            var dir = new DirectoryInfo(this.LocalPath);

            foreach (var grp in meta.XPathSelectElements("//" + _XML_TAG_METAFILE_ROOT + "/" + _XML_TAG_METAFILE_DIRLIST + "/" + _XML_TAG_METAFILE_DIR)
                     .Select(de =>
            {
                string maskedName = null;
                string realName;

                var maskedNameAttrib = de.Attribute(_XML_ATTRIB_METAFILE_MASKEDNAME);
                if (maskedNameAttrib != null)
                {
                    maskedName = maskedNameAttrib.Value;
                }

                var realNameAttrib = de.Attribute(_XML_ATTRIB_METAFILE_REALNAME);
                if (realNameAttrib == null ||
                    string.IsNullOrWhiteSpace(realNameAttrib.Value))
                {
                    realName = maskedName;
                }
                else
                {
                    realName = realNameAttrib.Value.Trim();
                }

                return(new
                {
                    MaskedName = maskedName,
                    RealName = realName,
                    XmlElement = de,
                });
            }).Where(i => string.IsNullOrWhiteSpace(i.MaskedName) == false &&
                     string.IsNullOrWhiteSpace(i.RealName) == false)
                     .GroupBy(i => i.MaskedName.ToLower().Trim()))
            {
                var item = grp.Last();

                var maskedDir = new DirectoryInfo(Path.Combine(dir.FullName, item.MaskedName));
                if (maskedDir.Exists == false)
                {
                    continue;
                }

                var newDir = new CloudPrincipalDirectory()
                {
                    FileManager = this.FileManager,
                    IsRoot      = false,
                    LocalPath   = maskedDir.FullName,
                    Parent      = this,
                    Xml         = item.XmlElement,
                };
                newDir.SetName(item.RealName);

                newDir.RefreshTimestamps();

                yield return(newDir);
            }
        }
        // Public Methods (6) 

        public IDirectory CreateDirectory(IEnumerable <char> name)
        {
            lock (this.FileManager.SyncRoot)
            {
                var realName = name.AsString();
                if (realName == null)
                {
                    throw new ArgumentNullException("realName");
                }

                realName = realName.Trim();
                if (realName == string.Empty)
                {
                    throw new ArgumentException("realName");
                }

                var deleteMaskDirOnFailure = false;
                var maskedDir = this.GetNextMaskedDirectory();
                try
                {
                    var meta = this.TryGetMetaData();
                    if (meta == null)
                    {
                        // current meta data could not be read or was not found
                        meta = new XDocument(new XDeclaration("1.0", Encoding.UTF8.WebName, "yes"));
                    }

                    var directoryElement = meta.Root;
                    if (directoryElement == null)
                    {
                        // root element does not exist

                        directoryElement = new XElement(_XML_TAG_METAFILE_ROOT);
                        meta.Add(directoryElement);
                    }

                    var dirListElement = directoryElement.Elements(_XML_TAG_METAFILE_DIRLIST).SingleOrDefault();
                    if (dirListElement == null)
                    {
                        // directory list element does not exist

                        dirListElement = new XElement(_XML_TAG_METAFILE_DIRLIST);
                        directoryElement.Add(dirListElement);
                    }

                    // try find existing entry
                    var dirElement = CollectionHelper.SingleOrDefault(dirListElement.Elements(_XML_TAG_METAFILE_DIR),
                                                                      e =>
                    {
                        var realNameAttrib = e.Attribute(_XML_ATTRIB_METAFILE_MASKEDNAME);
                        if (realNameAttrib != null)
                        {
                            return((realNameAttrib.Value ?? string.Empty).ToLower().Trim() ==
                                   realName.ToLower().Trim());
                        }

                        return(false);
                    });

                    if (dirElement == null)
                    {
                        // no entry found => create new one

                        maskedDir = Directory.CreateDirectory(maskedDir.FullName);
                        deleteMaskDirOnFailure = true;

                        dirElement = new XElement(_XML_TAG_METAFILE_DIR);
                        dirElement.SetAttributeValue(_XML_ATTRIB_METAFILE_REALNAME, realName);
                        dirElement.SetAttributeValue(_XML_ATTRIB_METAFILE_MASKEDNAME, maskedDir.Name);

                        dirListElement.Add(dirElement);
                    }
                    else
                    {
                        var maskedNameAttrib = dirElement.Attribute(_XML_ATTRIB_METAFILE_MASKEDNAME);
                        if (maskedNameAttrib != null &&
                            string.IsNullOrWhiteSpace(maskedNameAttrib.Value) == false)
                        {
                            maskedDir = new DirectoryInfo(Path.Combine(this.LocalPath,
                                                                       maskedNameAttrib.Value.Trim()));
                        }
                    }

                    // update meta data
                    this.UpdateMetaData(meta);

                    var result = new CloudPrincipalDirectory();
                    result.FileManager = this.FileManager;
                    result.LocalPath   = maskedDir.FullName;
                    result.Parent      = this;
                    result.Xml         = directoryElement;
                    result.SetName(realName);

                    // try update timestamps
                    try
                    {
                        maskedDir.Refresh();

                        var actions = new Action <CloudPrincipalDirectory, DirectoryInfo>[]
                        {
                            (cloudDir, localDir) => cloudDir.CreationTime = localDir.CreationTimeUtc,
                            (cloudDir, localDir) => cloudDir.WriteTime    = localDir.LastWriteTimeUtc,
                        };
                        actions.ForAll(ctx => ctx.Item(result, maskedDir),
                                       throwExceptions: false);
                    }
                    catch
                    {
                        // ignore errors here
                    }

                    return(result);
                }
                catch
                {
                    if (deleteMaskDirOnFailure)
                    {
                        if (maskedDir != null)
                        {
                            maskedDir.Refresh();
                            if (maskedDir.Exists)
                            {
                                maskedDir.Delete();
                                maskedDir.Refresh();
                            }
                        }
                    }

                    throw;
                }
            }
        }