private void GetDirectoryData(DirectoryInfo directoryInfo, DirectoryData parent)
        {
            // Get directory access control
            DirectorySecurity accessControl;
            try
            {
                accessControl = directoryInfo.GetAccessControl(AccessControlSections.Access);
            }
            catch (UnauthorizedAccessException ex)
            {
                OnErrorOccurred("Can't get access to directory " + directoryInfo.Name, ex);
                throw;
            }

            // Get current directory properties
            FileSystemObjectProperties properties = GetFileSystemObjectProperties(directoryInfo, accessControl);
            var directoryData = new DirectoryData(properties, parent);
            if (parent != null)
                parent.AddFileSystemObject(directoryData);
            OnGotNewFileSystemData(directoryData);

            // Get data for all nested files and directories
            foreach (DirectoryInfo directory in directoryInfo.GetDirectories())
            {
                if (_isAborted)
                    return;
                GetDirectoryData(directory, directoryData);
            }
            foreach (FileInfo file in directoryInfo.GetFiles())
            {
                if (_isAborted)
                    return;
                GetFileData(file, directoryData);
            }
        }
        private void GetFileData(FileInfo fileInfo, DirectoryData parent)
        {
            // Get file access control
            FileSecurity accessControl;
            try
            {
                accessControl = fileInfo.GetAccessControl(AccessControlSections.Access);
            }
            catch (UnauthorizedAccessException ex)
            {
                OnErrorOccurred("Can't get access to file " + fileInfo.Name, ex);
                throw;
            }

            FileSystemObjectProperties properties = GetFileSystemObjectProperties(fileInfo, accessControl);
            var fileData = new FileData(properties, parent, fileInfo.Length);
            parent.AddFileSystemObject(fileData);
            OnGotNewFileSystemData(fileData);
        }