Jump to content

Search the Community

Showing results for tags 'ifileoperation'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Delphi Questions and Answers
    • Algorithms, Data Structures and Class Design
    • VCL
    • FMX
    • RTL and Delphi Object Pascal
    • Databases
    • Network, Cloud and Web
    • Windows API
    • Cross-platform
    • Delphi IDE and APIs
    • General Help
    • Delphi Third-Party
  • C++Builder Questions and Answers
    • General Help
  • General Discussions
    • Embarcadero Lounge
    • Tips / Blogs / Tutorials / Videos
    • Job Opportunities / Coder for Hire
    • I made this
  • Software Development
    • Project Planning and -Management
    • Software Testing and Quality Assurance
  • Community
    • Community Management

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Delphi-Version

Found 1 result

  1. function CopyFileIFileOperationForceDirectories(const srcFile, destFile : string) : boolean; //works on Windows >= Vista and 2008 server var r : HRESULT; fileOp: IFileOperation; siSrcFile: IShellItem; siDestFolder: IShellItem; destFileFolder, destFileName : string; pbc : IBindCtx; w32fd : TWin32FindData; ifs : TFileSystemBindData; begin result := false; destFileFolder := ExtractFileDir(destFile); destFileName := ExtractFileName(destFile); //init com r := CoInitializeEx(nil, COINIT_APARTMENTTHREADED or COINIT_DISABLE_OLE1DDE); if Succeeded(r) then begin //create IFileOperation interface r := CoCreateInstance(CLSID_FileOperation, nil, CLSCTX_ALL, IFileOperation, fileOp); if Succeeded(r) then begin //set operations flags r := fileOp.SetOperationFlags(FOF_FILESONLY OR FOF_NORECURSION OR FOF_NOCONFIRMATION OR FOFX_NOMINIMIZEBOX); if Succeeded(r) then begin //get source shell item r := SHCreateItemFromParsingName(PChar(srcFile), nil, IShellItem, siSrcFile); if Succeeded(r) then begin //create binding context to pretend there is a folder there if NOT DirectoryExists(destFileFolder) then begin ZeroMemory(@w32fd, Sizeof(TWin32FindData)); w32fd.dwFileAttributes := FILE_ATTRIBUTE_DIRECTORY; ifs := TFileSystemBindData.Create; ifs.SetFindData(w32fd); r := CreateBindCtx(0, pbc); r := pbc.RegisterObjectParam(STR_FILE_SYS_BIND_DATA, ifs); end else pbc := nil; //get destination folder shell item r := SHCreateItemFromParsingName(PChar(destFileFolder), pbc, IShellItem, siDestFolder); //add copy operation if Succeeded(r) then r := fileOp.CopyItem(siSrcFile, siDestFolder, PChar(destFileName), nil); end; //execute if Succeeded(r) then r := fileOp.PerformOperations; result := Succeeded(r); OleCheck(r); end; end; CoUninitialize; end; end; when i issue the command to copy, it copies all of the subfolders when all i want it the specified folder only. CopyFileIFileOperationForceDirectories('c:\dir1', 'd:\dir1') it shows the copying of c:\dir1 to d:\dir1 but then when that is done it shows to be copying c:\dir1\subdir1 and all of its files. i only wish to copy the directory and none of the subfolders
×