PDA

View Full Version : Newbie needs help with DeleteFile and DeleteDir



Borg2of7
05-31-2004, 08:09 AM
Hello!
I need help with the DeleteFile and DeleteDir command.

how can i tell the Setup that it should delete write-protected files as well and how do I use TARGETDIR in that command?

can someone show me script for this commands?

the files which need to be deletet are in the fillowing directory:

TARGETDIR\Scripts


The complete scripts directory is write protected with all subdirectorys and files in it.

Thank You.

Borg

dwatson
05-31-2004, 08:52 AM
Hi,

I have created my own function that I use when I want to delete a folder.. and I want to make sure any Read-Only files get deleted as well.

prototype DeleteFiles(STRING);

//---------------------------------------------------------
// Function - DeleteFiles()
//
// Event - Delete all files and folders located in the
// path passed to this function
//
// Argument - svDir (The Directory to Delete)
//---------------------------------------------------------
function DeleteFiles(svDir)
STRING svFileSpec, svFile;
NUMBER nResult;
begin
svFileSpec = "*.*";
nResult = FindAllFiles (svDir, svFileSpec, svFile, RESET);

while(nResult = 0)
SetFileInfo ( svFile, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "" );
DeleteFile(svFile);

nResult = FindAllFiles(svDir, svFileSpec, svFile, CONTINUE);

endwhile;

DeleteDir(svDir,ALLCONTENTS);
end;

To use this function - DeleteFiles(INSTALLDIR ^ "Scripts");

Borg2of7
05-31-2004, 01:18 PM
When I this function o my script I get a big list of errors while compiling.

Borg2of7
06-01-2004, 03:34 AM
Does someone else know something about this???

Brandon Lowe
06-09-2004, 04:43 PM
The above function should work fine.
What list of errors do you get?

Brandon

Borg2of7
06-09-2004, 04:46 PM
Function is not needed anymore...I've reconfigured all files in the scripts directory... sorry for wasting your time