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. Problem with Folder access

Problem with Folder access

Scheduled Pinned Locked Moved Visual Basic
helpdebuggingbeta-testingannouncement
3 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.
  • S Offline
    S Offline
    soporificeffect
    wrote on last edited by
    #1

    Hi, I have a small problem with folder deletion from a VB application. It's a bit long, so bare with me. I have a form that upon its initialization a folder is created using MkDir. When the form unloads, in its Terminate event the folder is being deleted using RmDir. in between, temporary files are written in to the folder, and deleted from it. My problematic scenario is this: 1. the folder is created. 2. files are written. 3. files are deleted. and here is where the problem starts: on one computer (debug computer), the RmDir throws an exception of access denied, because a process is locking the folder, but I ignore this error, and when I load the form again, I ignore the error the MkDir throws, and everything seems to work fine (except for the fact that the folder isn't deleted). on another computer (which also happens to be the QA, and thus really important), again the folder is not deleted (I don't know if there is an error or not - can't debug), but it is also not accessible anymore. Since it is not accessible, when I re-load the form and try to create the folder again, I get an error. The folder is in limbo. when i close the application (and its process dies) the folder is deleted. my two main goals are a) figure out why the computers are behaving differently b) figure out a way to find out what locks the folder, and release the lock. The only workaround we found, was not to create the same folder each time , but that requires a lot of code changes to VB code as well as C code, as well as not prevent accumulation of temporary folders in my system, both of which I would like to avoid. Any help would be amazing. Thanks. :-D P.S. - in case it was not clear - this is VB6 code.

    D 1 Reply Last reply
    0
    • S soporificeffect

      Hi, I have a small problem with folder deletion from a VB application. It's a bit long, so bare with me. I have a form that upon its initialization a folder is created using MkDir. When the form unloads, in its Terminate event the folder is being deleted using RmDir. in between, temporary files are written in to the folder, and deleted from it. My problematic scenario is this: 1. the folder is created. 2. files are written. 3. files are deleted. and here is where the problem starts: on one computer (debug computer), the RmDir throws an exception of access denied, because a process is locking the folder, but I ignore this error, and when I load the form again, I ignore the error the MkDir throws, and everything seems to work fine (except for the fact that the folder isn't deleted). on another computer (which also happens to be the QA, and thus really important), again the folder is not deleted (I don't know if there is an error or not - can't debug), but it is also not accessible anymore. Since it is not accessible, when I re-load the form and try to create the folder again, I get an error. The folder is in limbo. when i close the application (and its process dies) the folder is deleted. my two main goals are a) figure out why the computers are behaving differently b) figure out a way to find out what locks the folder, and release the lock. The only workaround we found, was not to create the same folder each time , but that requires a lot of code changes to VB code as well as C code, as well as not prevent accumulation of temporary folders in my system, both of which I would like to avoid. Any help would be amazing. Thanks. :-D P.S. - in case it was not clear - this is VB6 code.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      soporificeffect wrote:

      the RmDir throws an exception of access denied, because a process is locking the folder, but I ignore this error

      Do you have a command prompt open or a DOS-based app running with this folder as the current directory?? A Windows process cannot "lock" the folder itself, only the files in it. If there is a file in that folder that is open, you cannot remove the folder that contains it, be it a DOS or Windows process. Is the folder empty when you try and RmDir it?? There can be no files in it when you do this. Do you have a virus scanner running, indexing service, or something else going on "behind the scenes"?? Disable it and try your app again.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      modified on Tuesday, December 04, 2007 2:11:25 PM

      S 1 Reply Last reply
      0
      • D Dave Kreskowiak

        soporificeffect wrote:

        the RmDir throws an exception of access denied, because a process is locking the folder, but I ignore this error

        Do you have a command prompt open or a DOS-based app running with this folder as the current directory?? A Windows process cannot "lock" the folder itself, only the files in it. If there is a file in that folder that is open, you cannot remove the folder that contains it, be it a DOS or Windows process. Is the folder empty when you try and RmDir it?? There can be no files in it when you do this. Do you have a virus scanner running, indexing service, or something else going on "behind the scenes"?? Disable it and try your app again.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        modified on Tuesday, December 04, 2007 2:11:25 PM

        S Offline
        S Offline
        soporificeffect
        wrote on last edited by
        #3

        I delete all the files before I try to remove the folder. the folder is empty. there are no applications using this folder. I'm not sure what services run in the background, but it is not possible to disable them. All this also does not explain how on the second computer the folder ends up in "Limbo", I can see it in the windows explorer, but I can't access it, it's as if the RmDir hasn't finished running, because the second the app closes the folder is gone

        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