Exemple #1
0
        protected void Update(AllFiles allFiles, string realPathDir)
        {
            string readDir = Path.Combine(Directory.GetCurrentDirectory(), realPathDir);
            string realPath = null;

            this.Contents.Clear();

            foreach (string file in Directory.GetFiles(readDir))
            {
                realPath = Path.Combine(realPathDir, Path.GetFileName(file));
                if (!allFiles.Any(f =>
                    Path.Equals(f.RealPath, realPath)))
                    this.Add(new OtherFile()
                    {
                        Name = Path.GetFileName(file),
                        RealPath = realPath,
                    });
            }
            foreach (string dir in Directory.GetDirectories(readDir))
            {
                realPath = Path.Combine(realPathDir, Path.GetFileName(dir));
                OtherFilesFolder child = new OtherFilesFolder()
                {
                    Name = Path.GetFileName(dir),
                    RealPath = realPath,
                };
                child.Update(allFiles,  Path.Combine(realPathDir, child.Name));
                this.Add(child);
            }
        }
Exemple #2
0
        private void UpdateOtherFiles(OtherFilesFolder folder, AllFiles allFiles, string savePathDir)
        {
            string pathOffset = Path.GetDirectoryName(SavePath);
            string realPath = null;

            foreach (string file in Directory.GetFiles(savePathDir))
            {
                realPath = file.Substring(pathOffset.Length + (pathOffset.EndsWith("\\")? 0 : 1));
                if (!allFiles.Any(f =>
                    Path.Equals(f.RealPath, realPath)))
                    folder.Add(new OtherFile()
                    {
                        Name = Path.GetFileName(file),
                        RealPath = realPath
                    });
            }
            foreach (string dir in Directory.GetDirectories(savePathDir))
            {
                OtherFilesFolder child = new OtherFilesFolder()
                {
                    Name = Path.GetFileName(dir),
                };
                UpdateOtherFiles(child, allFiles, dir+"\\");
                folder.Add(child);
            }
        }