コード例 #1
0
ファイル: BrowserViewModel.cs プロジェクト: alinadr/ShellTC
        public void GoToPath(string pathToGo)
        {
            try
            {
                if (!pathToGo.Substring(0, 3).Equals(Drive.Path))
                {
                    Drive = (FolderShell)AllDrives[AllDrives.IndexOf(AllDrives.Where(item => item.Path.Equals(pathToGo.Substring(0, 3))).First())];
                }
                FileAttributes attr = File.GetAttributes(pathToGo);

                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    Path = pathToGo;
                }
                else
                {
                    Path = pathToGo.Substring(0, pathToGo.LastIndexOf('\\'));
                }

                FolderShell f = new FolderShell(Path);
                List<ShellObject> obj = f.Folders.Concat(f.Files).ToList();
                AllObjects = new ReadOnlyObservableCollection<ShellObject>(new ObservableCollection<ShellObject>(obj));
            }
            catch (Exception e)
            {
                Path = Drive.Path;
                MessageWindow mw = new MessageWindow();
                MessageWindowViewModel.Instance.Message = e.Message;
                mw.ShowDialog();
            }
        }
コード例 #2
0
ファイル: FolderShell.cs プロジェクト: alinadr/ShellTC
 //public long countSize()
 //{
 //    long size = 0;
 //    string[] allFiles = Directory.GetFiles(Path, "*.*", SearchOption.AllDirectories);
 //    foreach (var file in allFiles)
 //    {
 //        size += file.Length;
 //    }
 //    return size;
 //}
 //private void GetDirectorySize(string directory)
 //{
 //    foreach (string dir in Directory.GetDirectories(directory))
 //    {
 //        GetDirectorySize(dir);
 //    }
 //    foreach (FileInfo file in new DirectoryInfo(directory).GetFiles())
 //    {
 //        this.Size += file.Length;
 //    }
 //}
 public static void ResponceToTheException(Exception except)
 {
     MessageWindow mw = new MessageWindow();
     MessageWindowViewModel.Instance.Message = except.Message;
     mw.ShowDialog();
 }
コード例 #3
0
ファイル: BrowserViewModel.cs プロジェクト: alinadr/ShellTC
 public static void ResponceToTheException(Exception except, string message = null)
 {
     MessageWindow mw = new MessageWindow();
     if (String.IsNullOrEmpty(message))
     {
         MessageWindowViewModel.Instance.Message = except.Message;
     }
     else
     {
         MessageWindowViewModel.Instance.Message = message;
     }
     mw.ShowDialog();
 }