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 , , ?