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:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: copy file
quote:
Originally posted by whiz
I'd like to ask a related question.  How can you delete a file?  And does it work with folders?
No offence but you should start trying the easy stuff yourself first then post if you cannot get it to work...

js code:
function DeleteFile(lpstrFile) {
    return Interop.Call('kernel32', 'DeleteFileW', lpstrFile) !== 0;
}

To remove a directory:
js code:
/* do not include trailing slashes, pass the path as c:\\test */
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 */)){
            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 02:55 PM by matty.
07-14-2009 01:51 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