请delphi大师写一个类似邮箱添加附件的程序
来源:百度知道 编辑:UC知道 时间:2024/06/09 04:11:39
请大侠再指点迷津:把所有动态显示出来的文件(实体文件)保存至c:\ab文件夹怎么写?要让菜鸟做难呐
先在窗体上放一个OpenDialog控件
//声明一个全局变量
var
c:integer;
//在附件的单击事件里写下面的代码。
var
Newlabel:Tlabel;
begin
if OpenDialog1.Execute then
if (OpenDialog1.FileName<>'') and (FileExists(OpenDialog1.FileName)) then
begin
Newlabel:=TLabel.Create(self);
Newlabel.Caption:=OpenDialog1.FileName;
Newlabel.AutoSize:=True;
Newlabel.Left:=200;
Newlabel.Top:=50+(20*c);
Newlabel.Parent:=Self;
Newlabel.Width:=Newlabel.Width+10;
Newlabel.tag:=c+1; //补充:加上这句
Inc(c);
end;
end;
--------------------------------------------
保存至c:\ab文件夹 ,就是复制文件吧。
用copyfile函数
下面是帮助里的copyfile说明:
The CopyFile function copies an existing file to a new file.
BOOL CopyFile(
LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag f