What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » copy file

copy file
Author: Message:
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
RE: copy file
quote:
Originally posted by matty
js code:
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));
    }
}

The folder and files remain, along with two errors.  One in the debugger...
quote:
Originally posted by JavaScript Debugger
code:
The handle is invalid.

...and a Windows alert (title: "Error Deleting File or Folder", message: "Cannot delete file: Cannot read from the source file or disk.").

EDIT: No... you don't need trailing slashes.  Let me try again.

EDIT 2: It works!  And it has a Windows confirm dialog box.  Thank you!

This post was edited on 08-10-2009 at 07:32 PM by whiz.
07-15-2009 08:14 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
copy file - by ainain on 05-25-2009 at 05:20 PM
RE: copy file - by matty on 05-25-2009 at 05:36 PM
RE: copy file - by ainain on 05-30-2009 at 03:38 PM
RE: copy file - by Mnjul on 05-30-2009 at 03:49 PM
RE: copy file - by wincy on 05-30-2009 at 10:29 PM
RE: copy file - by whiz on 07-14-2009 at 01:10 PM
RE: copy file - by NanaFreak on 07-14-2009 at 01:15 PM
RE: copy file - by matty on 07-14-2009 at 01:51 PM
RE: RE: copy file - by whiz on 07-14-2009 at 02:22 PM
RE: copy file - by matty on 07-14-2009 at 02:29 PM
RE: copy file - by whiz on 07-14-2009 at 02:51 PM
RE: copy file - by matty on 07-14-2009 at 02:53 PM
RE: copy file - by whiz on 07-14-2009 at 02:58 PM
RE: copy file - by matty on 07-14-2009 at 03:03 PM
RE: copy file - by whiz on 07-14-2009 at 03:19 PM
RE: copy file - by matty on 07-14-2009 at 03:27 PM
RE: copy file - by whiz on 07-14-2009 at 03:33 PM
RE: copy file - by matty on 07-14-2009 at 06:17 PM
RE: copy file - by whiz on 07-14-2009 at 07:24 PM
RE: copy file - by matty on 07-15-2009 at 12:43 PM
RE: RE: copy file - by whiz on 07-15-2009 at 06:31 PM
RE: copy file - by matty on 07-15-2009 at 07:57 PM
RE: copy file - by whiz on 07-15-2009 at 08:14 PM
RE: copy file - by CookieRevised on 07-15-2009 at 11:23 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On