Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / delete non-Empty folder or send folder/file to recycle bin

Author
Message
basjak
15
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 12th Sep 2014 10:19 Edited at: 12th Sep 2014 12:33
Hi Guys:

I think the title explains itself. Please have a look at my code and see why is not working.

many of you may suggest to empty the folder from file and subfolders but actually, in many cases it causing me a lot of crashes. as well, I need what the title says:



by the way there was a post in 2009 to address similar issue but just tried it this morning and didn't work.

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 12th Sep 2014 14:31
You cannot count on sending an array to get its data pointer.
Try make memory and push the arguments to there, or into a memblock (in which case you would use get memblock ptr when calling the DLL function) and it will probably work.


"Why do programmers get Halloween and Christmas mixed up?"
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 13th Sep 2014 01:34 Edited at: 13th Sep 2014 01:48
Basjak, your code works just fine for me. I use UDT Arrays quite often to pass structures to Windows API functions and never had a problem. But, yes any pointer will do whether, memblock or make memory. I really don’t think in your case it will make any difference.

WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 13th Sep 2014 01:46 Edited at: 13th Sep 2014 01:46
This is the code I use to delete the files and directories extracted from the zip file created by FPSCreator.



basjak
15
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 13th Sep 2014 08:28
Thanks guys. I'll have a look at it today and leave the result on this post.

@WickedX: the code you presented is absolutely fine but this was causing my program crash and I believe because the starts go be very big any complex.

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 13th Sep 2014 13:25
Alright, just brushed up on how the DBPro arrays are stored and I suppose a dereferenced array will indeed resolve to a pointer to said element.

If you want to code it yourself you could make a recursive function that stores all folders and files found in a certain directory using find first / find next to two separate, local arrays, then calls itself for any subdirectories, then deletes the subdirectories and finally deletes all files.
This will resolve to all files in a directory being deleted, followed by the folder itself being deleted and so on, from the bottom and up and will thus delete all files and sub-directories.


"Why do programmers get Halloween and Christmas mixed up?"
basjak
15
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 13th Sep 2014 21:43
@Rudolpho:
I really want shell32 to be used for program stability.

However, just tried the very same code(back to the beginning of the thread) and it worked fine on my computer.

my computer, is windows 8 home edition while my friend computer is win 7 business edition.

do you think it's win security issue?

basjak
15
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 13th Sep 2014 21:47
guys,

something really strange!!!!

I just added the line "add memblock 1, 256" without even using this memblock and it worked.

what' going on?

Login to post a reply

Server time is: 2025-06-28 20:50:46
Your offset time is: 2025-06-28 20:50:46