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. Web Development
  3. ASP.NET
  4. deleting a folder

deleting a folder

Scheduled Pinned Locked Moved ASP.NET
sysadmin
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.
  • S Offline
    S Offline
    Soumini Ramakrishnan
    wrote on last edited by
    #1

    I have an aspx website.I am trying to delete one user. While deleting I need to delete all files in one directory named "username" and after that the directory itself. The program deletes the files , but while deleting the directory it throws an exception saying "The directory is not empty". I am using the following code if (System.IO.Directory.Exists(Server .MapPath ("Albums/username" )) { System.IO.Directory.Delete(Server .MapPath ("Albums/username")); } If you double click on the folder, you will see an empty one. But if the folder's properties is taken, it shows that it contains a file with size 8 KB. Note: I am using this folder to store some images.

    P L 2 Replies Last reply
    0
    • S Soumini Ramakrishnan

      I have an aspx website.I am trying to delete one user. While deleting I need to delete all files in one directory named "username" and after that the directory itself. The program deletes the files , but while deleting the directory it throws an exception saying "The directory is not empty". I am using the following code if (System.IO.Directory.Exists(Server .MapPath ("Albums/username" )) { System.IO.Directory.Delete(Server .MapPath ("Albums/username")); } If you double click on the folder, you will see an empty one. But if the folder's properties is taken, it shows that it contains a file with size 8 KB. Note: I am using this folder to store some images.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Directory.Delete takes a second argument which, when set to true, causes all subdirectories and files to be deleted from the specified directory.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      1 Reply Last reply
      0
      • S Soumini Ramakrishnan

        I have an aspx website.I am trying to delete one user. While deleting I need to delete all files in one directory named "username" and after that the directory itself. The program deletes the files , but while deleting the directory it throws an exception saying "The directory is not empty". I am using the following code if (System.IO.Directory.Exists(Server .MapPath ("Albums/username" )) { System.IO.Directory.Delete(Server .MapPath ("Albums/username")); } If you double click on the folder, you will see an empty one. But if the folder's properties is taken, it shows that it contains a file with size 8 KB. Note: I am using this folder to store some images.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Soumini Ramakrishnan wrote:

        If you double click on the folder, you will see an empty one. But if the folder's properties is taken, it shows that it contains a file with size 8 KB.

        Are hidden file's and system file's displays on?

        "Sometimes the greatest journey is the distance between two people" - Nice quote from a Nice Indian Movie

        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