Delphi中对硬盘上的文件进行复制、删除、移动的语句如何写?(100分)

B

bboom

Unregistered / Unconfirmed
GUEST, unregistred user!
十万火急,请高手们帮忙。[red][/red]
 
拷贝用CopyFile,
删除有DeleteFile,
移动用MoveFile,
 
田伯光:
没有copyfile和movefile的函数啊?
 
需要
Uses WinApi
 
上面人兄说的对
 
如何引用winapi呢?直接在Unit中Uses WinAPI吗,
可是提示‘File not find:winapi.dcu’?如何处理?
 
Uses shellApi
 
copyFile(参数1;参数2;参数3;)三个参数应该怎么写?
 
Delphi自带的demo也可以参考参考:
/Program Files/Borland/Delphi5/Demos/Doc/Filmanex
 
Delphi的函数用法:
Function CopyFile(SourceFile:pchar;Destination FileName:pchar;Flag:Boolean):boolean;
参数:SourecFile:已经存在的文件名称;
Destination FileName:被复制的文件名称;
Flag:文件已经存在时的处理方式,False:表示覆盖;True:表示中止;
Exmaple:
将C:/Autoexec.Bat复制为D:/Tst.Wen;
CopyFile(pchar('c:/Autoexec.Bat'),Pcar('D:/Tst.Wen'),False);
 
http://xiaoyi26.y365.com/delphi/HSDQ1.htm
这是我的网站,相信有你需要的东东!
 
copy 的进度怎么知道?
windowsx 中的copy 文件进度有时狗屁不通,一下到%99然后等很久。。
 
这了一有个copyfile的例子,自己看吧:
procedure TForm1.Button2Click(Sender: TObject);
var
path_source:string;
path_destination:string;
begin
if opendialog1.Execute then
path_source:=opendialog1.FileName;
if savedialog1.Execute then
path_destination:=savedialog1.FileName;
copyfile(pchar(path_source),pchar(path_destination+'.mdb'),false);
end;
 
还没有搞定么?
 
请参考下面的源代码:
procedure fileoperation(const source,dest:string;op,flags:integer);
var
shf:tshfileopstruct;
s1,s2:string;
begin
fillchar(shf,sizeof(shf),#0);
s1:=source+#0#0;
s2:=dest+#0#0;
shf.Wnd:=0;
shf.wFunc:=op;
shf.pFrom:=pchar(s1);
shf.pTo:=pchar(s2);
shf.fFlags:=flags;
shfileoperation(shf);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
fileoperation('c:/zcjsj/*.*','c:/temp',fo_copy,fof_allowundo+fof_noconfirmation);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
fileoperation('c:/temp/zcjsj.exe','',fo_delete,fof_allowundo+fof_noconfirmation);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
fileoperation('c:/zcjsj/zcjsj.exe','c:/temp',fo_move,fof_allowundo+fof_noconfirmation);
end;
 
up up day day up
 
用AssignFile然后Writeln这样也可以拷贝文件和移动文件,还有使用文件流的方法,方法很多
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
764
import
I
顶部