I've been trying to delete a directory (with files in it) through DXL. I've tried calling the "System(string)" function, passing it the 'del' command, the '/S /F /Q' flags and the directory name, but it seems to do nothing. I've also tried the same command using win32SystemWait function, but that doesn't seem to be doing it either. I found the confDeleteDirectory function in the reference manual, but I can't seem to get it to work the way I need it to. At this point, I feel like I'm spinning my wheels. Anyone have any ideas? woodpryan - Fri May 01 13:14:55 EDT 2015 |
Re: Can I delete a directory through DXL?
here you go...
void removeDirectory( string directory )
{
string cmd = "cmd /c rd " directory " /s /q"
string cmdOutput = ""
win32SystemWait_( cmd, cmdOutput, -1 )
}
|
Re: Can I delete a directory through DXL? a8155058 - Mon May 04 08:33:54 EDT 2015
here you go...
void removeDirectory( string directory )
{
string cmd = "cmd /c rd " directory " /s /q"
string cmdOutput = ""
win32SystemWait_( cmd, cmdOutput, -1 )
}
Thank you so much for your help. This worked out quite nicely. I did slightly modify the function as follows:
/* Function: removeDirectory(string)
Purpose: deletes the given directoy and everything inside of it
Parameters: the directory name
Return: whether the directory could succesfully be deleted
*/
bool removeDirectory(string dirName)
{
string cmd = null
string cmdOutput = null;
if(null != dirName)
dirName = "\"" dirName "\"";
else
{
logError("The name passed to removeDirectory was null");
return false;
}
cmd = "cmd /c rd " dirName " /s /q";
win32SystemWait_( cmd, cmdOutput, -1 );
if(null != cmdOutput)
{
logError("Could not remove the directory because of the following error\n" cmdOutput);
return false;
}
return true;
}
But, yeah, the idea works beautifully. Thank you so much for your help. |