Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Delete a folder


3 replies to this topic

anjalai

anjalai
  • Members
  • 15 posts

Posted 06 November 2003 - 23:43

Hi,
I am trying to delete afolder using the following script
prototype DeleteDirectory(STRING); //accepts a directory path
function DeleteDirectory(directory)
STRING fileName;

begin
while ( FindFile(directory, "*.*", fileName)=0 ) //Finds all files in a directory
SetFileInfo(directory^fileName, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, ""); //resets files attributes to NORMAL
DeleteFile(directory^fileName); //Delete File
endwhile;
DeleteDir(directory, ALLCONTENTS);
end;

My directory has some subdirectoryies in it.
I have been finding a way to delte the folder which has some files and subdirectories.It's not delteing it, unles I explicitly remove the read only attribute in the top level folder.
Please let me now if there is work around.
Thnaks
a

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 07 November 2003 - 01:08

I'm not sure why you need to programmatically delete all this stuff instead of letting say the uninstall process take care of it for you, but in any case ...

Yes, that's a known limitation with DeleteFile/DeleteDir which is why I see you followed the IS Knowledge Base Article Q105082. However, as you discovered that only covers read-only files & not read-only folders.

To workaround the problem though, I would try creating a batch to do the delete and then simply call it from your InstallScript.

Oh, and in the future, I don't suggest installing read-only files/folders unless absolutely necessary for just this reason.

Edited by Taco Bell, 07 November 2003 - 01:09.

user posted image

anjalai

anjalai
  • Members
  • 15 posts

Posted 07 November 2003 - 17:40

Hi Taco,
Thanks for your reply,
No this folder is the Back up folder which is the copy of our stuff from the previous install.
Can you please let me know how to call the Batch files to delete a folder and the folder name is set via IS script.
Thanks
A

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 08 November 2003 - 01:46

Just use LaunchAppAndWait to call the batch file. See the help for more information about this function.
user posted image