Take a look at this:
http://msdn.microsoft.com/en-us/library/aa365488%28VS.85%29.aspx
Anyways it looks like I completly screwed it up that time. I will have another stab at it.
js code:
RemoveDirectory('C:\\Documents and Settings\\User\\My Documents\\Test');
function RemoveDirectory(sPath) {
var FO_DELETE = 0x3
var FOF_ALLOWUNDO = 0x40;
var SHFILEOPSTRUCT = Interop.Allocate(30);
var strPath = Interop.Allocate(sPath.length*2+2);
strPath.WriteString(0, sPath);
with (SHFILEOPSTRUCT) {
WriteDWORD(0, 0);
WriteDWORD(4, FO_DELETE);
WriteDWORD(8, strPath.DataPtr);
//WriteWORD(16, FOF_ALLOWUNDO); // If you want the files to be sent to the recycle bin uncomment the following
}
if ( Interop.Call('shell32', 'SHFileOperationW', SHFILEOPSTRUCT) > 0 ) TraceWin32Error();
}
function TraceWin32Error(){
var LastError = Interop.GetLastError();
if(LastError != 0) {
var MsgBuffer = Interop.Allocate(1024);
Interop.Call("Kernel32", "FormatMessageW", 0x1000, 0, LastError, 0, MsgBuffer, 1024, 0);
Debug.Trace(MsgBuffer.ReadString(0));
}
}