edit1 edit2的值中已经包括了目录和文件名.如:c:\my docments\aaa.mdb
解决方案 »
- 報表小問題,放份....
- 我不知道爱情怎么会这样....
- 在线:关于TRealAudio控件无法播放Tmemorystream的问题(难道该控件只能关联调用吗???)......
- 用Exception.Create(...)代替MessageBox显示一些消息,是否可取?
- 控件的名字是一个变量,怎样根据这个名字得到该控件 ?
- 如何将程序中字符串变量的内容写到文件中去?在线等。急!
- 关于Clientdataset的问题,小弟在线等待!急急!
- 为什么自定义对象持久化失败
- 这里有个项目,哪个公司可以接,进来看一下
- 我用ado连接access 数据库 , 可是程序报告“非法的精确度值“,这是为什么呀?
- 初级问题,请高手指点,在线等待
- sql中能不能进行日期的比较?送分,别见笑
这样Edit1.text取到的包括路径!
在copyfile(pchar(edit1.text),pchar(edit2.text),false);
这样Edit1.text取到的包括路径!
在copyfile(pchar(edit1.text),pchar(edit2.text),false);
edit2.text:=savedialog1.filename;
copyfile(pchar(edit1.text),pchar(edit2.text),false);
可是这样执行了以后,还是没有将edit1.text的文件复制到edit2.text的位置。
为什么呀!
不解呀... 太痛苦了!!!
效果不错!
有什么不一样.
用过很多次,不错!
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;
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;
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.
edit2.text:=copy(edit1.text,1,length(edit1.text));
锁定文件关闭,并执行复制过程呀!。
edit1.text:=opendialog1.filename;
edit2.text:=savedialog1.filename;
copyfile(pchar(edit1.text),pchar(edit2.text),false);
文件,我这也遇到过这问题,先将所有的连接断开。