示例#1
0
        private void BuildDirNode(string dirPath, DirNode parent, bool handleSMBAttributes)
        {
            dirPath = AppendDirectorySeparator(dirPath);

            DateTimeOffset?creationTime   = null;
            DateTimeOffset?lastWriteTime  = null;
            FileAttributes?fileAttributes = null;

#if DOTNET5_4
            LongPathFileExtension.GetFileProperties(dirPath, out creationTime, out lastWriteTime, out fileAttributes, true);
#else
            LongPathFileExtension.GetFileProperties(dirPath, out creationTime, out lastWriteTime, out fileAttributes);
#endif

            parent.CreationTime  = creationTime;
            parent.LastWriteTime = lastWriteTime;

            foreach (var fileInfo in LongPathDirectoryExtension.GetFiles(dirPath))
            {
                FileNode fileNode = new FileNode(fileInfo.Remove(0, dirPath.Length));
                this.BuildFileNode(fileInfo, fileNode, handleSMBAttributes);
                parent.AddFileNode(fileNode);
            }

            foreach (var subDirInfo in LongPathDirectoryExtension.GetDirectories(dirPath))
            {
                DirNode subDirNode = new DirNode(subDirInfo.Remove(0, dirPath.Length));
                this.BuildDirNode(subDirInfo, subDirNode, handleSMBAttributes);
                parent.AddDirNode(subDirNode);
            }
        }
        private void BuildDirNode(string dirPath, DirNode parent)
        {
            dirPath = AppendDirectorySeparator(dirPath);
            foreach (var fileInfo in LongPathDirectoryExtension.GetFiles(dirPath))
            {
                FileNode fileNode = new FileNode(fileInfo.Remove(0, dirPath.Length));
                this.BuildFileNode(fileInfo, fileNode);
                parent.AddFileNode(fileNode);
            }

            foreach (var subDirInfo in LongPathDirectoryExtension.GetDirectories(dirPath))
            {
                DirNode subDirNode = new DirNode(subDirInfo.Remove(0, dirPath.Length));
                this.BuildDirNode(subDirInfo, subDirNode);
                parent.AddDirNode(subDirNode);
            }
        }