Creating directories during copying using IFileOperation

Using the Stephen Toub IFileOperation shell for C # ( link ), which still works. Now I'm trying to make a copy to collect files from network locations, each network location in its own subdirectory.

\\FOO\datain C:\gather\Foo_data
\\BAR\manage\currentinC:\gather\bar\manage

Etc. The problem is FileOperation.CopyItem. This should be because the target directory does not exist yet - IFileOperationwill create it during copying, right? I used the technique from another question and changed Toub FileOperation.CreateShellItemto this:

private static ComReleaser<IShellItem> CreateShellItem( string path )
{
    try
    {
        return new ComReleaser<IShellItem>( (IShellItem)SHCreateItemFromParsingName( path, null, ref _shellItemGuid ) );
    }
    catch ( FileNotFoundException )
    {
        IntPtr pidl = SHSimpleIDListFromPath( path );
        IShellItem isi = (IShellItem)SHCreateItemFromIDList( pidl, ref _shellItemGuid );
        Marshal.FreeCoTaskMem( pidl );
        System.Diagnostics.Debug.WriteLine( "Shell item: " + isi.GetDisplayName( SIGDN.DesktopAbsoluteParsing ) );
        return new ComReleaser<IShellItem>( isi );
    }
}

I am stuck there Debug.WriteLineto check that it works, and it seems that it works fine; he writes the way back.

IFileOperation.CopyItem ArgumentException, , . "IShellItem "? , SFGAO_FOLDER , IShellItem , , ?

+5
1

Google ( - ) .

  • COM- , IFileSystemBindData.
  • WIN32_FIND_DATA dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY. ( , .)
  • IFileSystemBindData.
  • WIN32_FIND_DATA IFileSystemBindData::SetFindData.
  • IBindCtx.
  • IBindCtx::RegisterObjectParam STR_FILE_SYS_BIND_DATA (#define d L"File System Bind Data") IFileSystemBindData.
  • SHCreateItemFromParsingName IBindCtx.

. binding-context SHCreateItemFromParsingName , . IFileOperation, D:\Some\Path\That\Did\Not\Previously\Exist, . , IShellItem , , dwFileAttributes.

. , . ++; , COM-, #. , , ++.

+6

All Articles