Пример #1
0
 public ItemViewModel(FileInfo file, ItemViewModel parent)
 {
     ParentFolder = parent;
     Path = file.FullName;
     Name = file.Name;
     Extension = file.Extension;
 }
Пример #2
0
        public ItemViewModel(DirectoryInfo dir, ItemViewModel parent)
        {
            ParentFolder = parent;
            IsFolder = true;
            Path = dir.FullName;
            Name = dir.Name;

            DirectoryInfo[] subfolders = null;
            try
            {
                subfolders = dir.GetDirectories();
            }
            catch { }

            SubFolders = new List<ItemViewModel>();
            if (subfolders != null)
            {
                foreach (var d in subfolders)
                {
                    SubFolders.Add(new ItemViewModel(d, this));
                }
            }

            FileInfo[] files = null;
            try
            {
                files = dir.GetFiles();
            }
            catch { }

            Files = new List<ItemViewModel>();
            if (files != null)
            {
                foreach (var f in files)
                {
                    Files.Add(new ItemViewModel(f, this));
                }
            }
        }
Пример #3
0
        public void RemoveFolder(ItemViewModel folder)
        {
            if (!SyncFolders.Contains(folder)) return;

            SyncFolders.Remove(folder);
            //should i save here?
            Save();
        }
Пример #4
0
        public void AddFolder(DirectoryInfo dir)
        {
            if (SyncFolders.Any(s => s.Path == dir.FullName && s.Name == dir.Name))
            {
                return;
            }

            var syncFolder = new ItemViewModel(dir, null);

            SyncFolders.Add(syncFolder);
            //should i save here?
            Save();
        }