matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: copy file
Try this: js code: RemoveDirectory('C:\\This\\Is\\The\\Directory\\To\\Delete\\');
function RemoveDirectory(sPath) {
var WIN32_FIND_DATA = Interop.Allocate(592);
var hSearch = Interop.Call('kernel32', 'FindFirstFileW', sPath+'*', WIN32_FIND_DATA);
var hResult = -1;
while(hResult != 0){
if(!(WIN32_FIND_DATA.ReadDWORD(0) & 0x10 /* FILE_ATTRIBUTE_DIRECTORY */)){
Interop.Call('kernel32', 'DeleteFileW', '\\\\?\\'+sPath+WIN32_FIND_DATA.ReadString(44));
} else {
RemoveDirectory(sPath+WIN32_FIND_DATA.ReadString(44));
Interop.Call('kernel32', 'RemoveDirectoryW', '\\\\?\\'+sPath+WIN32_FIND_DATA.ReadString(44));
}
hResult = Interop.Call('kernel32', 'FindNextFileW', hSearch, WIN32_FIND_DATA)
}
Interop.Call('kernel32', 'FindClose', hSearch);
}
This post was edited on 07-14-2009 at 03:08 PM by matty.
|
|