3 Replies Latest reply on Jun 3, 2010 4:35 PM by chris.campbell

    Delete Windows Sample Pictures

    ScottFriebel

      I had a problem trying to delete some folders created with my application and finally came to find that I was unable to programmatically delete any folder that had any of the photos from the default Windows Sample Pictures folder copied into it. Is there a way I would be able to delete that new folder including those images? It seems that since the images are copies and not the originals I should have more control in that regard.

       

      Thanks for any help,

       

      Scott F.

        • 1. Re: Delete Windows Sample Pictures
          chris.campbell Adobe Employee

          Hi Scott,

          I was unable to reproduce this using the Windows 7 sample pictures.  I copied a couple over to a test folder and my AIR app was able to delete the folder right away.  Are you passing in true when you call deleteDirectory() or deleteDirectoryAsync()?  Are you able to delete them using Explorer?

           

          Chris

          • 2. Re: Delete Windows Sample Pictures
            ScottFriebel Level 1

            I'm not sure what conditions could be causing it to not work for me. I've tried to narrow it down to something specific but, I get an error whether the program copies the files or I copy them using windows explorer into the folder its trying to delete. Also, the program usually renames them when copying, but I get the error whether they have been renamed or not. I am able to delete the folder using windows explorer without a problem. Using the exact same sequence of events, it runs without a problem except when using those sample pictures, where I get the error every time.

             

            I've noticed some strange things when working with those sample images. The software renames the images when it copies them to a folder in the ApplicationStorageDirectory. I watched the images appear there, renamed as they should be, then refreshed the folder a few seconds later and the images were their original names again - without changing anything myself and without the program running any code at all. However, the software references them using the 'renamed' name of the file and it still works, even though those files don't appear with that changed name in windows explorer anymore. I have been using Vista sample images, and my colleague has been using windows 7 images - both are behaving the same way. However, he just copied some of his images to my computer, and the software is able to rename (and they stay renamed), and delete those images without a problem. The only difference I can find is in the properties of the files, the files that originated on my computer have an Owner "SYSTEM", and the files that originated on his computer and have been copied to my computer have an Owner *My username*.

             

            Sorry for the long post, hopefully it makes some sense

             

            The error code is:

            Error #3012: Cannot delete file or directory.

             

            Below are the lines of code to delete the folder:

             

            var images:File = File.applicationStorageDirectory.resolvePath("ProjectImages/" + name);

            if(pimages.exists) {

                 try {

                      images.deleteDirectory(true);

                 } catch(err:IOError) {

                      trace(err);

                 }

            }

            • 3. Re: Delete Windows Sample Pictures
              chris.campbell Adobe Employee

              That's odd.  My guess is that it's a Windows access control issue (which AIR currently does not have functionality to deal with).  For the problematic files, if you open up the access and give the current user account full control do the problems go away?

               

              Chris