Page 1 of 1
Posted: Mon Dec 09, 2002 11:40 am
by BackupUser
Restored from previous forum. Originally posted by JoRo.
I have the problem, that I am not able to delete a directory. The files inside the directory were deleted, but the directory itself not. I have even tried it with Api-commands, but no effect.
The folder has the attribute "protected". It is not possible, to change this attribute, it remains protected.
The system is Windows XP home, SP1.
Can someone give me a hint, how to get it work?
Johannes
Posted: Mon Dec 09, 2002 2:55 pm
by BackupUser
Restored from previous forum. Originally posted by blueb.
Johannes,
Have you tried the API fuction:
shFileOperation
It has the ability to delete files and folders.
Check out:
http://www.reelmediaproductions.com/pb/ ... Folder.zip
Regards,
blueb
Posted: Wed Dec 11, 2002 7:27 am
by BackupUser
Restored from previous forum. Originally posted by JoRo.
Yes, I have taken the ShFileOP. But after installing XP it does not work. I use the ShOP to move the directory to the trashfolder.
Now I am wondering, that even the build in functions of Pure are not able to delete a folder, only files.
Johannes
Posted: Wed Dec 11, 2002 11:30 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.
> Now I am wondering, that even the build in functions of Pure are not able
> to delete a folder, only files.
Well, you said the folder is protected.
That means the folder is protected...
cya,
...Danilo
(registered PureBasic user)
Posted: Wed Dec 11, 2002 1:11 pm
by BackupUser
Restored from previous forum. Originally posted by JoRo.
Hi Danillo,
the folder was just created with PureBasic. There are no flags, that say, that it should be protected. It is a problem of windows xp home. It is very well protected. Security is first. And this causes, that you are not able ´to delete a folder you have created just before. As long, as the programm, which created the folder or read the directory with examine directory is not closed, the folder is protected by windows xp. And there must be an opportunity, to override these protection by the programm, else, it is impossible to delete a folder under WindowsXP home. This is a general problem, not a personal.
Johannes
Posted: Wed Dec 11, 2002 1:48 pm
by BackupUser
Restored from previous forum. Originally posted by tranquil.
Best solution: de-install XP and install 2000
But I know some kind of Problem with WindowsCommander. It deletes all entrys of a directory recursive but not the folders inside the root-folder. dont know why. I need to delete them manually and then it works. possible a NTFS Feature!?
Cheers
Mike
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
Posted: Fri Dec 13, 2002 11:04 am
by BackupUser
Restored from previous forum. Originally posted by PB.
Hi Joro,
This works perfectly for me with Win XP Professional (haven't tested
it with XP Home). If it doesn't work for you, then can you please
post the code you're using so I can see if you're doing something
a little bit wrong? Or, try the code at the following link:
http://www.curvesoftware.co.uk/purebasi ... PIC_ID=725
Code: Select all
CreateDirectory("c:\zzz") ; Create a directory.
Delay(2000) ; Wait 2 seconds so we can see if it exists.
DeleteDirectory("c:\zzz","*.*") ; Delete it.
Posted: Fri Dec 13, 2002 1:16 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Originally posted by JoRo
you are not able ´to delete a folder you have created just before. As long, as the programm, which created the folder or read the directory with examine directory is not closed, the folder is protected by
Sounds like the ExamineDirectory keeps a lock on the directory it most recently examined. No OS would allow you to delete something which has locks on it.
Is there a command for releasing ExamineDirectory? Or maybe you could try examining a directory called "" or something else?
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
Posted: Mon Dec 16, 2002 6:17 pm
by BackupUser
Restored from previous forum. Originally posted by JoRo.
Hi PB,
thanks for the hint. Your example works well.
I have found the protection. Deleting an directory which doesent exists may cause heavy crashes, so it usual to give the command inside an if .
CreateDirectory("c:\zzz") ; Create a directory.
Delay(2000) ; Wait 2 seconds so we can see if it exists.
If ExamineDirectory(1,"c:\zzz","*.*")
DeleteDirectory("c:\zzz","*.*") ; Delete it
EndIf
This causes the protection. Now, deleting the directory is not possible.
Well on ME it works, on XP not.
Johannes
Posted: Mon Dec 16, 2002 10:36 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Originally posted by JoRo
If ExamineDirectory(1,"c:\zzz","*.*")
DeleteDirectory("c:\zzz","*.*") ; Delete it
EndIf
This causes the protection. Now, deleting the directory is not possible.
Well on ME it works, on XP not.
Did you try doing as I suggested? If you try to delete the directory using your code then your program will have an active lock on it, and so it may not get deleted (I do not know exactly how Windows works in this respect, but it would make sense and is how other OSes work). Unfortunately your code works OK on my computer (Win98) so I cannot test if one way works and another does not.
Something like this:
If ExamineDirectory(1,"c:\zzz","*.*")
; Work with directory
ExamineDirectory("", "") ; Try to release directory?
DeleteDirectory("c:\zzz","*.*") ; Delete it
EndIf
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
Posted: Mon Dec 16, 2002 10:53 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
Originally posted by JoRo
Hi PB,
thanks for the hint. Your example works well.
I have found the protection. Deleting an directory which doesent exists may cause heavy crashes, so it usual to give the command inside an if .
CreateDirectory("c:\zzz") ; Create a directory.
Delay(2000) ; Wait 2 seconds so we can see if it exists.
If ExamineDirectory(1,"c:\zzz","*.*")
DeleteDirectory("c:\zzz","*.*") ; Delete it
EndIf
This causes the protection. Now, deleting the directory is not possible.
Well on ME it works, on XP not.
Johannes
If you're afraid to try deleting a directory that doesn't exist, try using the 'FileSize()' command it returns -2 if it's a directory you're testing size on..I don't think this command locks the directory..
Posted: Tue Dec 17, 2002 7:08 pm
by BackupUser
Restored from previous forum. Originally posted by JoRo.
Hi tinman,
yes I tried your example by using the UseDirectory(). This changes the actual used directory. But it had no effect.
It is not the examinedirectory itself, only inside the if-construction.
So the problem is easy to solve in my code, I will delete the if-construction.
The name of the directory is extract before by an examine directory. So, it was only typical in my codeconstruction to use the if, but not really necessary.
(to pupil: I will test it with the filesize command)
Johannes