Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Gadgets
Windows Sidebar
System.Shell.Folder
Methods
 System.Shell.Folder.copyHere method
System.Shell.Folder.copyHere method

[ The Windows Gadget Platform/Sidebar is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. ]

Applies to: desktop apps only

Copies a System.Shell.Item to a folder.

Syntax

System.Shell.Folder.copyHere(
  oItem,
  [ intOptions = 0 ]
)

Parameters

oItem [in]

The System.Shell.Item to copy.

intOptions [in, optional]

Integer that specifies any combination of copy operation options.

Note   These values are based on flags defined for use with the fFlags member of the C++ SHFILEOPSTRUCT structure. These flags are not defined for Microsoft Visual Basic, Visual Basic Scripting Edition (VBScript), or Microsoft JScript, so you must define the values or use their numeric equivalents.

(0)

Default. No options specified.

(4)

Do not display a progress dialog box.

(8)

Rename the target file if a file exists at the target location with the same name.

(16)

Click "Yes to All" in any dialog box displayed.

(64)

Preserve undo information, if possible.

(128)

Perform the operation only if a wildcard file name (*.*) is specified.

(256)

Display a progress dialog box but do not show the file names.

(512)

Do not confirm the creation of a new directory if the operation requires one to be created.

(1024)

Do not display a user interface if an error occurs.

(4096)

Disable recursion.

(8192)

Do not copy connected files as a group. Only copy the specified files.

Return value

This method does not return a value.

Remarks

A Shell folder object must be obtained from a System.Shell.Item using the SHFolder property in order to perform this call.

Examples

The following example demonstrates how to copy an object to a system folder.

// Member variables.
var oShellFolderItem;
var oShellFolder;

// --------------------------------------------------------------------
// Display the folder picker dialog and get a Shell.Item object 
// from the selection. A Shell folder object is also obtained.
// --------------------------------------------------------------------
function ChooseAFolder()
{
    oShellFolderItem = System.Shell.chooseFolder("SDK Choose Folder Example", 0);
    if (oShellFolderItem)
    {
        // Get a folder object from the System.Shell.Item.
        oShellFolder = oShellFolderItem.SHFolder;
    }
}

// --------------------------------------------------------------------
// Display the names of objects dropped on the gadget.
// Objects are deleted, copied, or moved as required.
// --------------------------------------------------------------------
function GetItemFromDrop()
{    
    var intIndex = 0;
    var oItem;
    while(oItem = System.Shell.itemFromFileDrop(event.dataTransfer, intIndex))
    {
        // Delete object as required.
        if (deleteDrop.checked == true)
        {
            System.Shell.RecycleBin.deleteItem(oItem.path);
        }
        
        // Copy object as required.
        if ((copyDrop.checked == true) && (oShellFolder!= null))
        {
            try
            {
                oShellFolder.copyHere(oItem, 8);
            }
            catch (e)
            {
                // Error handling.
            }
        }
        
        // Move object as required.
        if ((moveDrop.checked == true) && (oShellFolder != null))
        {
            try
            {
                oShellFolder.moveHere(oItem, 8);
            }
            catch (e)
            {
                // Error handling.
            }
        }
        
        intIndex++;
    }
}

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

End of client support

Windows 8 Consumer Preview

End of server support

Windows Server 8 Beta

IDL

Sidebar.idl

DLL

Sidebar.Exe (version 1.00 or later)

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Option "16"      Маскаль Валерий   |   Edit   |   Show History
Yeap, "16" didnt work.
Tags What's this?: Add a tag
Flag as ContentBug
IntOptions 16 does not work      Jens_0 ... Thomas Lee   |   Edit   |   Show History
The prompt whether to overwrite files in destination folder cannot be automated with flag 16 (yes to all) as described here. Apparently, according to internet sources, this is a bug.
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker