Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        { // LoadDrives
            locations = new Stack();
            LoadDrives();

            Drive = new USB(GetDrive());
        }
Ejemplo n.º 2
0
        private void GetContents(String location)
        {// Enter in the folder
            Drive = new USB(location);

            var Dir = new DirectoryInfo(location);

            foreach (var folder in Dir.GetDirectories())
            {
                // MessageBox.Show(folder.Name);
                ListViewItem item = new ListViewItem();
                item.Text       = folder.Name;
                item.ImageIndex = 0;
                item.SubItems.Add(folder.FullName);
                listView1.Items.Add(item);
            }

            foreach (FileInfo File in Dir.GetFiles())
            {
                String extension = File.Extension;
                if (!imageList1.Images.Keys.Contains(extension))
                {
                    imageList1.Images.Add(extension, Icon.ExtractAssociatedIcon(File.FullName));
                }
                int          index = imageList1.Images.Keys.IndexOf(extension);
                ListViewItem item  = new ListViewItem();
                item.Text       = File.Name;
                item.ImageIndex = index;
                item.SubItems.Add(File.FullName);
                listView1.Items.Add(item);
            }
        }
Ejemplo n.º 3
0
        private void SelectTable()
        {
            if (listView1.SelectedItems.Count > 0)
            {
                String path    = listView1.SelectedItems[0].SubItems[1].Text;
                var    Folders = new DirectoryInfo(path);
                Drive = new USB(path);
                try
                {
                    listView1.Items.Clear();
                    foreach (DirectoryInfo folder in Folders.GetDirectories())
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text = folder.Name;
                        item.SubItems.Add(folder.FullName);
                        item.ImageIndex = 0;
                        listView1.Items.Add(item);
                    }
                    foreach (FileInfo file in Folders.GetFiles())
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text = file.Name;
                        item.SubItems.Add(file.FullName);

                        String extension = file.Extension;

                        if (!imageList1.Images.Keys.Contains(extension))
                        {
                            imageList1.Images.Add(extension, Icon.ExtractAssociatedIcon(file.FullName));
                        }

                        int index = imageList1.Images.Keys.IndexOf(extension);
                        item.ImageIndex = index;
                        listView1.Items.Add(item);
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message.ToString(), "Error"); }
            }
        }