Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Shileoperation with multiple destination

Posted on 2003-11-06
2
Medium Priority
?
145 Views
Last Modified: 2010-04-05
Hi, i have a code here but i have a problem.. I want to copy the files in a multiple directory in drive a but it only copy the first 'a:\backup' and the remaining is not copied..

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,shellApi;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  F:Tshfileopstruct;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
 sr:Tsearchrec;
 dir:string;
begin

  dir := 'a:\backup'+#0#0+'a:\backup3'+#0#0;
  if FindFirst('c:\backup3\*.zip',faAnyFile,sr) = 0 then
  begin
     if MessageDlg('Please insert diskette in dirve A:\', mtInformation, [mbOK,mbCancel],0) =  mrOk then
     begin
       F.wnd := handle;
       F.wfunc := FO_COPY;
       F.pfrom := pchar('c:\Backup3\*.zip');
       F.pto := pchar(dir);
       F.hNameMappings := NIL;
       F.Fflags := FOF_MULTIDESTFILES OR FOF_NOCONFIRMATION OR FOF_NOCONFIRMMKDIR;
       if shfileoperation(F) <> 0 then
          showmessage('File was not copied')
       else
          showmessage('File successfully copied.. Please Remove diskette in Drive A:\');
       end;
  end
  else
   showmessage('No files found in the backup3 folder...');

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
     Application.Terminate;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
    button2.SetFocus;
end;

end.
0
Comment
Question by:orafans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9693115
i guess

this
dir := 'a:\backup'+#0#0+'a:\backup3'+#0#0;
 
must be
dir := 'a:\backup'+#0+'a:\backup3'+#0#0;

but just a guess

meikl ;-)
 
0
 
LVL 5

Accepted Solution

by:
snehanshu earned 1000 total points
ID: 9693399
From
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvb4/html/msdn_fileopen.asp

FOF_MULTIDESTFILES Tells the SHFileOperation function that the pTo field specifies multiple destination files. In other words, each source file has a corresponding destination file. Otherwise, the files will be copied or moved to a single directory.

I think this needs to have a one to one correspondence.
So, if your pfrom is 'C:\Folder1\File1.txt'+#0+'C:\Folder2\File2.txt'+#0#0
then you can set pto to
'a:\Folder1\File1.txt'+#0+'a:\Folder2\File2.txt'+#0#0

But it is not to copy one file to many locations. (only for n Different files to n different locations)

That's my understanding.
...Shu
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question