コード例 #1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="directory">対象ディレクトリ</param>
        public DirectoryAnalyzer(DirectoryInfo directory)
        {
            this.currentDirectory = directory;

            this.progressData = new ProgressForm.ProgressData();
            this.progressForm = new ProgressForm(GetProgressValue);
        }
コード例 #2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="file">解析ファイル</param>
        /// <param name="progressData">進捗データ</param>
        /// <param name="rootData">大本の親フォルダの解析データ</param>
        public DirectoryAnalyzeData(FileSystemInfo file, ref ProgressForm.ProgressData progressData, DirectoryAnalyzeData rootData)
        {
            if (isCancel == true)
            {
                return;
            }

            this.rootData = rootData;
            if (rootData == null)
            {
                this.rootData = this;
            }

            FileAttributes attribute = file.Attributes;
            if ((attribute & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint)
            {
                // リパースポイントの場合は無視
                return;
            }

            FileSystemSecurity fileSecurity = null;
            // ファイルタイプの判別
            try
            {
                this.path = file.FullName;

                if ((attribute & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    this.fileType = FileTypeKind.Directory;

                    fileSecurity = ((DirectoryInfo)file).GetAccessControl();
                }
                else
                {
                    this.fileType = FileTypeKind.File;
                    this.size = ((FileInfo)file).Length;

                    fileSecurity = ((FileInfo)file).GetAccessControl();
                }
            }
            catch
            {
                // アクセス拒否の場合
                isAccessDeny = true;
            }

            try
            {
                this.owerName = string.Empty;
                if (fileSecurity != null)
                {
                    NTAccount account = (NTAccount)fileSecurity.GetOwner(typeof(NTAccount));
                    this.owerName = account.ToString();
                }
            }
            catch
            {
            }

            this.name = file.Name;
            this.extention = Path.GetExtension(this.path).ToLower();
            this.creationTime = file.CreationTime;
            this.lastModifyDate = file.LastWriteTime;
            this.lastAccessTime = file.LastAccessTime;
            this.isReadOnly = (attribute & FileAttributes.ReadOnly) == FileAttributes.ReadOnly;
            this.isHidden = (attribute & FileAttributes.Hidden) == FileAttributes.Hidden;

            this.files = new List<DirectoryAnalyzeData>();
            this.directories = new List<DirectoryAnalyzeData>();

            progressData.currentFileName = this.name;
            progressData.targetFolderName = Path.GetDirectoryName(path);
            progressData.progress++;

            if (this.FileType == FileTypeKind.Directory)
            {
                // ディレクトリの場合
                // 中のファイルの情報を取得
                try {
                    progressData.maxProgress += ((DirectoryInfo)file).GetFileSystemInfos().Length;

                    foreach (DirectoryInfo subDir in ((DirectoryInfo)file).GetDirectories())
                    {
                        DirectoryAnalyzeData data = new DirectoryAnalyzeData(subDir, ref progressData, this.rootData);

                        if (string.IsNullOrEmpty(data.Name) == false)
                        {
                            directories.Add(data);
                        }
                    }

                    foreach (FileInfo subFile in ((DirectoryInfo)file).GetFiles())
                    {
                        DirectoryAnalyzeData data = new DirectoryAnalyzeData(subFile, ref progressData, this.rootData);

                        if (string.IsNullOrEmpty(data.Name) == false)
                        {
                            files.Add(data);
                        }
                    }
                }
                catch
                {
                    // アクセス拒否の場合
                    isAccessDeny = true;
                }
            }

            this.attachData = new FileAttachData(path, isHidden, isAccessDeny);
        }
コード例 #3
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="path">ファイルパス</param>
 /// <param name="progressData">進捗データ</param>
 public DirectoryAnalyzeData(FileSystemInfo file, ref ProgressForm.ProgressData progressData)
     : this(file, ref progressData, null)
 {
 }