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. Visual Basic
  4. permission denied while deleting folder

permission denied while deleting folder

Scheduled Pinned Locked Moved Visual Basic
help
6 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.
  • J Offline
    J Offline
    jishbalan
    wrote on last edited by
    #1

    I cant able to delete a subfolder inside a folder. What i going is, opening a file from subfolder, reading it and closing the file and copying it to other folder and then deleting that file. Same i doing for all files in that subfolder. then checking that subfolder size if its size is zero, deleting it.. this is the code i used to delete the folder path = "c:\newfolder" For Each fld In path.SubFolders If fld.Size = 0 Then fld.Delete : here i am getting permission denied, error 70 End If Next fld I am closing all the FileSystemObjects. jishith

    L L 3 Replies Last reply
    0
    • J jishbalan

      I cant able to delete a subfolder inside a folder. What i going is, opening a file from subfolder, reading it and closing the file and copying it to other folder and then deleting that file. Same i doing for all files in that subfolder. then checking that subfolder size if its size is zero, deleting it.. this is the code i used to delete the folder path = "c:\newfolder" For Each fld In path.SubFolders If fld.Size = 0 Then fld.Delete : here i am getting permission denied, error 70 End If Next fld I am closing all the FileSystemObjects. jishith

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

      Is this in Vista? Run the file as an administrator?

      1 Reply Last reply
      0
      • J jishbalan

        I cant able to delete a subfolder inside a folder. What i going is, opening a file from subfolder, reading it and closing the file and copying it to other folder and then deleting that file. Same i doing for all files in that subfolder. then checking that subfolder size if its size is zero, deleting it.. this is the code i used to delete the folder path = "c:\newfolder" For Each fld In path.SubFolders If fld.Size = 0 Then fld.Delete : here i am getting permission denied, error 70 End If Next fld I am closing all the FileSystemObjects. jishith

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, there could be several reasons why a folder cannot be deleted: - it contains some files; checking its size against zero is not correct, what if there is an empty file? - the file you tried to delete in an attempt to empty the folder did not get deleted for one of many reasons - the folder is in use, e.g. there is a Windows Explorer window open showing it. - the folder was created by some one else, you don't have delete rights for it. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Good riddance W


        J 1 Reply Last reply
        0
        • L Luc Pattyn

          Hi, there could be several reasons why a folder cannot be deleted: - it contains some files; checking its size against zero is not correct, what if there is an empty file? - the file you tried to delete in an attempt to empty the folder did not get deleted for one of many reasons - the folder is in use, e.g. there is a Windows Explorer window open showing it. - the folder was created by some one else, you don't have delete rights for it. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Good riddance W


          J Offline
          J Offline
          jishbalan
          wrote on last edited by
          #4

          Hi, Thanks for replying. but.. 1) Checking the file folder size with 0 is not correct, here the folder is empty 2) I manually creating the folder, so no right issues 3) I can delete that folder, whn i am running my application for the next time. Only the first instance its showing permission denied. First i thought some oject is not releasing. But i making all the object i used in the function to nothing. Still it showing permission denied. If there are four folders, its deleting three folders and when its come to the last one, the permission is denied. How i make sure the folder is not in use? Or how to release the in use folder? Jishith

          1 Reply Last reply
          0
          • J jishbalan

            I cant able to delete a subfolder inside a folder. What i going is, opening a file from subfolder, reading it and closing the file and copying it to other folder and then deleting that file. Same i doing for all files in that subfolder. then checking that subfolder size if its size is zero, deleting it.. this is the code i used to delete the folder path = "c:\newfolder" For Each fld In path.SubFolders If fld.Size = 0 Then fld.Delete : here i am getting permission denied, error 70 End If Next fld I am closing all the FileSystemObjects. jishith

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

            Perhaps you are the one who has the folder in use? Can a reference to fld keep the folder "locked for editing"? Second question;

            For Each fld In path.SubFolders
            If fld.Size = 0 Then
            fld.Delete - Is this allowed in a foreach?
            End If
            Next fld

            I are troll :)

            J 1 Reply Last reply
            0
            • L Lost User

              Perhaps you are the one who has the folder in use? Can a reference to fld keep the folder "locked for editing"? Second question;

              For Each fld In path.SubFolders
              If fld.Size = 0 Then
              fld.Delete - Is this allowed in a foreach?
              End If
              Next fld

              I are troll :)

              J Offline
              J Offline
              jishbalan
              wrote on last edited by
              #6

              Thanks eddy, i resolved the error...

              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