whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
RE: RE: copy file
quote: Originally posted by matty
js code: function DeleteFile(lpstrFile) {
return Interop.Call('user32', 'DeleteFileW', lpstrFile) !== 0;
}
To remove a directory:
js code: function RemoveDirectory(sPath) {
var WIN32_FIND_DATA = Interop.Allocate(592);
var hSearch = Interop.Call('kernel32', 'FindFirstFileW', sPath+'\\*.*', WIN32_FIND_DATA);
var hResult;
while(hResult != 0){
if(!(WIN32_FIND_DATA.ReadDWORD(0) & 0x10 /* FILE_ATTRIBUTE_DIRECTORY */)){
DeleteFile(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);
}
quote: Originally posted by JavaScript Debugger
Error: unknown (code: -2147467259)
js code: /* error: */ return Interop.Call('user32', 'DeleteFileW', lpstrFile) !== 0;
|
|