예제 #1
0
        public override long CalcSize()
        {
            size = 0;
            Children.Clear();

            var fis = info.GetFiles();

            for (int i = 0; i < fis.Length; i++)
            {
                var item = new FileItem(fis[i]);
                Children.Add(item);
                size += item.CalcSize();
            }

            var dis = info.GetDirectories("*", SearchOption.TopDirectoryOnly);

            for (int i = 0; i < dis.Length; i++)
            {
                var item = new DirItem(dis[i]);
                Children.Add(item);
                size += item.CalcSize();
            }

            return(size);
        }
예제 #2
0
        private void btnCalc_Click(object sender, RoutedEventArgs e)
        {
            var dirPath = cbBaseDir.Text;

            if (!Directory.Exists(dirPath))
            {
                Debuger.LogError("目录不存在:{0}", dirPath);
                return;
            }

            AppPrefs.SetString("cbBaseDir", cbBaseDir.Text);
            AppPrefs.Save();

            m_current = new DirItem(new DirectoryInfo(dirPath));
            m_current.CalcSize();
            m_current.Sort((SortType)cbSortType.SelectedValue);

            List <DirItem> list = new List <DirItem>();

            list.Add(m_current);
            tvDirTree.ItemsSource = list;
        }