edit1 edit2的值中已经包括了目录和文件名.如:c:\my docments\aaa.mdb

解决方案 »

  1.   

    edit1.text:=opendialog1.filename;
    这样Edit1.text取到的包括路径!
    在copyfile(pchar(edit1.text),pchar(edit2.text),false);
      

  2.   

    edit1.text:=opendialog1.filename;
    这样Edit1.text取到的包括路径!
    在copyfile(pchar(edit1.text),pchar(edit2.text),false);
      

  3.   

    edit1.text:=opendialog1.filename;
    edit2.text:=savedialog1.filename;
    copyfile(pchar(edit1.text),pchar(edit2.text),false);
      

  4.   

    copyfile(pchar(edit1.text),pchar(edit2.text),false);
    可是这样执行了以后,还是没有将edit1.text的文件复制到edit2.text的位置。
    为什么呀!
    不解呀...                   太痛苦了!!!
      

  5.   

    我用的都是copyfileto(filestr1,filestr2),返回boolean
    效果不错!
      

  6.   

    copyfileto(filestr1,filestr2),返回boolean,true成功!false失败!
      

  7.   

    copyfile 和copyfileto
    有什么不一样.
      

  8.   

    没什么不一样!copyfileto需要idglobal的单元好象!
    用过很多次,不错!
      

  9.   

    var
         
         filename:string;//目标库文件名
         source,target: TFileStream;
         
    begin
         
         source:=TFileStream.Create('源库文件名',fmOpenRead );//支持路径、扩展名;
         try
           target:=TFileStream.Create(filename,fmOpenWrite or fmCreate);
           try
             if target.CopyFrom(source,source.Size)=source.Size then
               ShowMessage('成功备份到'+filename+'!!!');
           finally
             target.Free;
           end;
         finally
           source.Free;
         end;
      

  10.   

    var
         
         filename:string;//目标库文件名
         source,target: TFileStream;
         
    begin
         
         source:=TFileStream.Create('源库文件名',fmOpenRead );//支持路径、扩展名;
         try
           target:=TFileStream.Create(filename,fmOpenWrite or fmCreate);
           try
             if target.CopyFrom(source,source.Size)=source.Size then
               ShowMessage('成功备份到'+filename+'!!!');
           finally
             target.Free;
           end;
         finally
           source.Free;
         end;
      

  11.   

    可以的,我刚使了!!
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        OpenDialog1: TOpenDialog;
        SaveDialog1: TSaveDialog;
        Edit1: TEdit;
        Edit2: TEdit;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    begin
    copyfile(pchar(edit1.text),pchar(edit2.text),false);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
        if opendialog1.Execute then
        edit1.Text:=opendialog1.FileName;
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
        if savedialog1.Execute then
        edit2.Text:=savedialog1.FileName;
    end;end.
      

  12.   

    你的意思是拷贝文件还是拷贝字符串???
    edit2.text:=copy(edit1.text,1,length(edit1.text));
      

  13.   

    我试了一下,源程序没有问题,放在其他目录可以复制的。但是放在正在运行的程序目录下(已有.mdb)确不复制成功。查看了一下,原因可能是我用ado连接的mdb数据库文件,程序在运行时已在程序目录下产生一个数据库锁定文件,现在是如何将
    锁定文件关闭,并执行复制过程呀!。
      

  14.   

    : linx88(haozi) (  )  
     
    edit1.text:=opendialog1.filename;
    edit2.text:=savedialog1.filename;
    copyfile(pchar(edit1.text),pchar(edit2.text),false);
     
     
      

  15.   

    用ado连接mdb数据库文件,只要有任何连接,都不能复制
    文件,我这也遇到过这问题,先将所有的连接断开。