Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. CheckedListBox

CheckedListBox

Scheduled Pinned Locked Moved C#
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrithula8
    wrote on last edited by
    #1

    I tried to list drives available in a system in checkedlistbox.When i click on the C:\ i want to list its files in a listview.I tried with the following but it does not work.Can you give me an alternative.<pre> int p=checkedListBox1.SelectedIndex; if(p==1) { try { reader = new XmlTextReader("path.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Text: //Display the text in each element. // Console.WriteLine(reader.Value); String s1; s1 = reader.Value; String ss; ss = checkedListBox1.CheckedItems.ToString(); String sss = ss + s1; object o3 = (object)sss; DirectoryInfo dire = new DirectoryInfo(sss); //DirectoryInfo[] dirs = dire.GetDirectories(); if (dire.Exists) { String[] folder; folder = Directory.GetDirectories(sss); foreach (string foldername in folder) { DirectoryInfo di = new DirectoryInfo(foldername); if (di.Exists) { String[] files; files = Directory.GetFiles(foldername, "*.exe*"); //FileInfo[] fi = dire.GetFiles(); foreach (String filename in files) { lvi = new ListViewItem(); lvi.Text = filename; listView1.Items.Add(lvi); } this.Controls.Add(listView1); } } } break; }

    H 1 Reply Last reply
    0
    • M mrithula8

      I tried to list drives available in a system in checkedlistbox.When i click on the C:\ i want to list its files in a listview.I tried with the following but it does not work.Can you give me an alternative.<pre> int p=checkedListBox1.SelectedIndex; if(p==1) { try { reader = new XmlTextReader("path.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Text: //Display the text in each element. // Console.WriteLine(reader.Value); String s1; s1 = reader.Value; String ss; ss = checkedListBox1.CheckedItems.ToString(); String sss = ss + s1; object o3 = (object)sss; DirectoryInfo dire = new DirectoryInfo(sss); //DirectoryInfo[] dirs = dire.GetDirectories(); if (dire.Exists) { String[] folder; folder = Directory.GetDirectories(sss); foreach (string foldername in folder) { DirectoryInfo di = new DirectoryInfo(foldername); if (di.Exists) { String[] files; files = Directory.GetFiles(foldername, "*.exe*"); //FileInfo[] fi = dire.GetFiles(); foreach (String filename in files) { lvi = new ListViewItem(); lvi.Text = filename; listView1.Items.Add(lvi); } this.Controls.Add(listView1); } } } break; }

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      Two things. First you forgot to include the closing </pre> tag. Secondly, what you are trying to do is sort-of like Windows Explorer so a quick google on 'explorer c#' reveals My Explorer In C#[^], as the first hit. If that doesn't give you any ideas, google for yourself and have a look at some of the other hits.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups