Ejemplo n.º 1
0
        private void ShowDriveContents()
        {
            ShowingDrives = false;

            if (list_FolderBrowser != null) // ( This is needed because InitializeComponent calls this procedure. )
            {
                subEntries.Clear();

                try
                {
                    if (Directory.Exists(text_CurrentPath.Text))
                    {
                        foreach (string s in Directory.GetDirectories(text_CurrentPath.Text))
                        {
                            DirectoryInfo dir = new DirectoryInfo(s);
                            DirectoryEntry d = new DirectoryEntry(
                                dir.Name, dir.FullName, "<Folder>", "",
                                Directory.GetLastWriteTime(s),
                                "i/icon16-folder.png", EntryType.Dir
                                );
                            subEntries.Add(d);
                        }
                        foreach (string f in Directory.GetFiles(text_CurrentPath.Text))
                        {
                            FileInfo file = new FileInfo(f);
                            DirectoryEntry d = new DirectoryEntry(
                                file.Name, file.FullName, file.Extension, file.Length.ToString(),
                                file.LastWriteTime,
                                "i/icon16-file.png", EntryType.File
                                );
                            subEntries.Add(d);
                        }

                        list_FolderBrowser.DataContext = subEntries;
                    }
                }
                catch (Exception ex)
                {
                    Prompt = ex.Message;
                    System.Windows.MessageBox.Show(Prompt, "Problem", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                btn_UpOneLevel.IsEnabled = true;
            }
        }
Ejemplo n.º 2
0
 private void ShowDrives()
 {
     foreach (string s in Directory.GetLogicalDrives())
     {
         DirectoryEntry d = new DirectoryEntry(s, s, "<Driver>", "<DIR>", Directory.GetLastWriteTime(s), "Images/dir.gif", EntryType.Dir);
         entries.Add(d);
     }
     this.list_FolderBrowser.DataContext = entries;
     ShowingDrives = true;
     btn_UpOneLevel.IsEnabled = false;
 }
Ejemplo n.º 3
0
        private void list_FolderBrowser_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (list_FolderBrowser.SelectedIndex >= 0)
            {
                SaveInfoFile();

                DirectoryEntry entry = (DirectoryEntry)list_FolderBrowser.Items[list_FolderBrowser.SelectedIndex];

                text_CurrentPath.Text = entry.Fullpath;

                if (entry.Type == EntryType.Dir)
                {
                    subEntries.Clear();

                    try
                    {
                        foreach (string s in Directory.GetDirectories(entry.Fullpath))
                        {
                            DirectoryInfo dir = new DirectoryInfo(s);
                            DirectoryEntry d = new DirectoryEntry(
                                dir.Name, dir.FullName, "<Folder>", "",
                                Directory.GetLastWriteTime(s),
                                "i/icon16-file.png", EntryType.Dir
                                );
                            subEntries.Add(d);
                        }
                        foreach (string f in Directory.GetFiles(entry.Fullpath))
                        {
                            FileInfo file = new FileInfo(f);
                            DirectoryEntry d = new DirectoryEntry(
                                file.Name, file.FullName, file.Extension, file.Length.ToString(),
                                file.LastWriteTime,
                                "i/icon16-file.png", EntryType.File
                                );
                            subEntries.Add(d);
                        }
                    }
                    catch (Exception ex)
                    {
                        Prompt = ex.Message;
                        System.Windows.MessageBox.Show(Prompt, "Problem", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    finally
                    {
                        list_FolderBrowser.DataContext = subEntries;
                    }
                }
            }
        }