大家好:
我做了一个小程序,最后将数据填充到预先做好的excel表中,路径为c:\windows\desktop\xzry.xls,我想在程序中设置一个路径将这个文件拷贝到
指定的路径中,比如a:\中,我用了一个ShellComboBox1选择路径,代码如下:
//将数据保存到指定的路径:
newfile_xls:='c:\windows\desktop\新建文件夹\xzry.xls';
newfile_bc:=ShellCombobox1.root; if fileExists(newfile_bc+'\xzry.xls') then
deleteFile(newfile_bc+'\xzry.xls')
else
begin
CopyFile(newfile_bc+'\xzry.xls',newfile_xls);
exit;
end; if not fileExist(newfile_bc+'\xzry.xls') then
showmessage('报盘失败!请重新报盘')
else
showmessage('报盘结束!');为甚么不行呐?是不是use 中没有加该加的东西比如math等,我该如何做?请详细说明,我是初学者,勿怪!
我做了一个小程序,最后将数据填充到预先做好的excel表中,路径为c:\windows\desktop\xzry.xls,我想在程序中设置一个路径将这个文件拷贝到
指定的路径中,比如a:\中,我用了一个ShellComboBox1选择路径,代码如下:
//将数据保存到指定的路径:
newfile_xls:='c:\windows\desktop\新建文件夹\xzry.xls';
newfile_bc:=ShellCombobox1.root; if fileExists(newfile_bc+'\xzry.xls') then
deleteFile(newfile_bc+'\xzry.xls')
else
begin
CopyFile(newfile_bc+'\xzry.xls',newfile_xls);
exit;
end; if not fileExist(newfile_bc+'\xzry.xls') then
showmessage('报盘失败!请重新报盘')
else
showmessage('报盘结束!');为甚么不行呐?是不是use 中没有加该加的东西比如math等,我该如何做?请详细说明,我是初学者,勿怪!
strTmp : String;
testfile : String;
FilePath : String;
begin
testfile := 'c:\windows\desktop\新建文件夹\xzry.xls';
FilePath := 'C:\';
strTmp := '';
if length(testfile) > 0 then
begin
strTmp := FilePath+'xls\' + Extractfilename(testfile);
if not FileExists(strTmp) then
begin
CopyFile(PChar(testfile),PChar(strTmp),false);
end;
end;
testfile := 'c:\windows\desktop\新建文件夹\shhff\excel\银行报盘.xls';
FilePath := 'D:\';
strTmp := ''; if length(testfile) > 0 then
begin
strTmp := FilePath+'xls\' + Extractfilename(testfile);
if not FileExists(strTmp) then
begin
CopyFile(PChar(testfile),PChar(strTmp),false);
end;
end;