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);
            }
        }
 protected FileSystemObjectData(FileSystemObjectProperties properties, DirectoryData parent)
 {
     FileSystemRights = properties.FileSystemRights;
     Owner = properties.Owner;
     Attributes = properties.Attributes;
     LastAccessTime = properties.LastAccessTime;
     LastWriteTime = properties.LastWriteTime;
     CreationTime = properties.CreationTime;
     Name = properties.Name;
     Parent = parent;
 }
 protected FileSystemObjectData(FileSystemObjectProperties properties, DirectoryData parent)
 {
     FileSystemRights = properties.FileSystemRights;
     Owner            = properties.Owner;
     Attributes       = properties.Attributes;
     LastAccessTime   = properties.LastAccessTime;
     LastWriteTime    = properties.LastWriteTime;
     CreationTime     = properties.CreationTime;
     Name             = properties.Name;
     Parent           = parent;
 }
Exemple #4
0
 public DirectoryData(FileSystemObjectProperties properties, DirectoryData parent)
     : base(properties, parent)
 {
 }
        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);
        }
 public DirectoryData(FileSystemObjectProperties properties, DirectoryData parent)
     : base(properties, parent)
 {
 }