Page 2 of 2
Posted: Wed Jan 30, 2002 2:34 pm
by BackupUser
Restored from previous forum. Originally posted by Ralf.
> aha . that 's the reason.
Yep. So modify your procedure a bit to remove the emptied directories as soon
as all the files have been deleted in each one, and it'll work just fine.
That's to hard for me !
> This RemoveDirectory_(dir$), where is it from ?
It's a Win32 API command which is built-in to all Windows versions.
PB - Registered PureBasic Coder
Edited by - PB on 30 January 2002 14:15:14
Posted: Wed Jan 30, 2002 2:45 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> That's to hard for me !
Okay, I did it for you. Here's your whole procedure again. Note that you
don't even have to remove the top directory manually anymore, and that I added
some code to delete
all files and folders, even those which are marked as
system, hidden, or read-only (the lines starting with 'SetFileAttributes' does it).
Code: Select all
Procedure DelDirectory(DelDirectory$, Start)
If ExamineDirectory(Start, DelDirectory$, "*.*")
Repeat
Type = NextDirectoryEntry()
If Type = 2 ; Dir.
If DirectoryEntryName() "." And DirectoryEntryName() ".."
c$ = DelDirectory$+DirectoryEntryName()+"\"
DelDirectory(c$, Start+1)
UseDirectory(Start)
EndIf
Else
If Type = 1 ; File.
SetFileAttributes_(DelDirectory$+DirectoryEntryName(),#FILE_ATTRIBUTE_NORMAL)
DeleteFile(DelDirectory$+DirectoryEntryName())
EndIf
EndIf
Until Type=0 ; No more entries.
SetFileAttributes_(DelDirectory$,#FILE_ATTRIBUTE_NORMAL)
RemoveDirectory_(DelDirectory$) ; Remove empty dir as we go...
EndIf
EndProcedure
;
DelDirectory("C:\DOS99\",Start) ; Delete this folder and EVERYTHING inside it.
PB - Registered PureBasic Coder
Edited by - PB on 30 January 2002 14:55:43
Posted: Wed Jan 30, 2002 3:16 pm
by BackupUser
Restored from previous forum. Originally posted by Ralf.
worked great.
thanks a lot.
One simple line !?!?!?!?!?!?!?!?!?!?!
Edited by - ralf on 30 January 2002 15:17:27
Posted: Wed Jan 30, 2002 3:23 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
worked great.
thanks a lot.
One simple line !?!?!?!?!?!?!?!?!?!?!
Yep!
I have posted this code in the
Tips N Tricks section, along with some test
code, for others to use. Naturally I have credited you in the tip, as I couldn't
have done it without you.
PB - Registered PureBasic Coder
Posted: Wed Jan 30, 2002 3:27 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.
Why not add it to the archive on the Resources site?
Posted: Wed Jan 30, 2002 3:28 pm
by BackupUser
Restored from previous forum. Originally posted by Ralf.
Sorry !
Doesn't work for files which Have the attribute 'R' writeprotected.
Posted: Wed Jan 30, 2002 3:54 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> Why not add it to the archive on the Resources site?
I just did.
PB - Registered PureBasic Coder
Posted: Wed Jan 30, 2002 3:58 pm
by BackupUser
Restored from previous forum. Originally posted by Ralf.
I took the sample of tips 'n tricks and i worked.
So thanks a lot and don't worry.