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. How to delete some file from the ListView?

How to delete some file from the ListView?

Scheduled Pinned Locked Moved C#
3 Posts 3 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.
  • E Offline
    E Offline
    Eyungwah
    wrote on last edited by
    #1

    Hi, I have a ListView table that contains some files and i would like to know the command that will delete it by clicking some Delete Button. Thanks in advance for your help. Eyungwah

    CPalliniC S 2 Replies Last reply
    0
    • E Eyungwah

      Hi, I have a ListView table that contains some files and i would like to know the command that will delete it by clicking some Delete Button. Thanks in advance for your help. Eyungwah

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Probably you mean that ListView contains the path of the files. Then simply call File.Delete, passing the text of the ListView Items. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • E Eyungwah

        Hi, I have a ListView table that contains some files and i would like to know the command that will delete it by clicking some Delete Button. Thanks in advance for your help. Eyungwah

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        Well, you can use the ListView.SelectedItems property to retrieve a collection of all items that are currently selected. Iterate over the returned collection and for each item delete the respective file by using classes from System.IO namespace (if you really want to delete on the file system) and finally remove the item from the list view via ListView.Items.Remove method.


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        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