delete folder

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

delete folder

Post by jmburnod » Sun Dec 02, 2012 3:28 pm

Hi All,
I have a script to delete a folder, it work well on OSX and IOS but not on windows

Code: Select all

on delFolder pFolder
set the defaultfolder to pFolder
   put the files into tTheFiles
   repeat for each lines tFile in tTheFiles
      put pFolder & "/" & tFile into tPathFile
      delete file tPathFile
   end repeat
   delete folder pFolder
end delFolder
What is wrong ?

Thank
Jean-Marc
https://alternatic.ch

Klaus
Posts: 13821
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: delete folder

Post by Klaus » Sun Dec 02, 2012 3:41 pm

Hi Jean-Marc,

what does not work: deleting files or the folder?
Did you check "the result"?


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: delete folder

Post by jmburnod » Sun Dec 02, 2012 4:19 pm

hi Klaus,
Sorry,
I can't test on windows. It seem "delete folder" don't work (I don't know if all files are deleted)
That is a reply of Simon about this topic
http://forums.runrev.com/phpBB2/viewtop ... =8&t=13466
Best
Jean-Marc
https://alternatic.ch

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: delete folder

Post by sturgis » Sun Dec 02, 2012 4:45 pm

One thing you might try is setting the defaultfolder to another location before trying to delete the folder that was created. Worth a try to see if it makes a difference. There is a chance I guess that if you have the defaultfolder still pointing to the inside of the folder in question, the os might be hitting the "the folder is in use.." problem. /shrug. Worth a shot at least.

Code: Select all

   set the defaultfolder to specialfolderpath("documents")
   delete folder pFolder

Klaus
Posts: 13821
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: delete folder

Post by Klaus » Sun Dec 02, 2012 4:55 pm

Hi Jean-Marc,

yes, I think strugis hit the nail wit this one:
sturgis wrote:One thing you might try is setting the defaultfolder to another location before trying to delete the folder that was created. Worth a try to see if it makes a difference. There is a chance I guess that if you have the defaultfolder still pointing to the inside of the folder in question, the os might be hitting the "the folder is in use.." problem.
I bet this is the problem, good catch :D

Ususally I do not use the defaultfolder but rather use absolute pathnames. Except for getting its files, of course, but will reset it to the previous defaultfolder after that!
Some kind of "survival strategy" I developed of the last years while coding in Livecode! 8)



Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: delete folder

Post by FourthWorld » Sun Dec 02, 2012 7:51 pm

Simon only noted that he experienced the same problem, but as here there is no indication of *why* that happened.

Klaus has been using this language a long time, so I can assure you he's not wasting time when he suggests checking "the result" after the "delete folder" command.

Try it and let us know what you find.

I've used "delete folder" under a wide range of circumstances, and while I have had to accommodate the ocassional oddity with Windows, LiveCode itself has always handled it well. I'm sure with just a little diagnostic info we can resolve this for you.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: delete folder

Post by jmburnod » Mon Dec 03, 2012 12:09 pm

Hi,
Thanks for replys
I made a simple stack to check the results with the suggestion of sturgis
One btn create a new folder with a .txt file in documents folder and an other
delete it.
I can't try it. I haven't got windows
Somebody can test it it on windows ?

Best
Jean-Marc
Attachments
TestDeleteFolderWindows.livecode.zip
(1.5 KiB) Downloaded 312 times
https://alternatic.ch

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: delete folder

Post by Simon » Mon Dec 03, 2012 3:26 pm

Hi Jean-Marc,
That worked for me.
MyNewFolder and it's content was created and deleted.
Nice one Sturgis. I recall I have had troubles with delete folder in the past.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: delete folder

Post by jmburnod » Mon Dec 03, 2012 3:43 pm

Hi Simon,
Thank again.
That worked for me
Do you have test it in the "DownloadZipExtractOSX" stack also ?
Just to be sur that was the mistake
Best
Jean-Marc
https://alternatic.ch

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: delete folder

Post by Simon » Mon Dec 03, 2012 4:02 pm

Hi Jean-Marc,
In "DownloadZipExtractOSX" I changed:

Code: Select all

--•• delete folder pFolder
on delFolder pFolder
   set the defaultfolder to pFolder
   put the files into tTheFiles
   repeat for each lines tFile in tTheFiles
      put pFolder & "/" & tFile into tPathFile
      delete file tPathFile
   end repeat
--  from TestDeleteFolderWindows.livecode
   if the platform = "Win32"  then
      set the defaultfolder to specialfolderpath("documents") -- add sturgis 021212
   end if
   delete folder pFolder
end delFolder
and it did remove the folder Images50.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: delete folder

Post by jmburnod » Mon Dec 03, 2012 4:14 pm

Hi Simon,
Thank again. A mistake less
Best
Jean-Marc
https://alternatic.ch

Post Reply

Return to “Windows”