方法一:
①定义API:
Function ulong CopyFile(ref string lpExistingFileName,ref string lpNewFileName,ulong bFailIfExists) LIBRARY kernel32.dll" ALIAS FOR "CopyFileA"
说明:复制文件。
返回值: ulong,非零表示成功,零表示失败。
参数 类型及说明
lpExistingFileName String,源文件名。
lpNewFileName String,目标文件名。
bFailIfExists ulng,如果设为TRUE(非零),那么一旦目标文件已经存在,则函数调用会失败。否则目标文件被改写。
②脚本:
string str_source, str_des
ulong ulng_result
str_source = "c:/lag.txt" //源文件
str_des = "c:/tmp/111.txt" //目标文件
ulng_result=CopyFile(str_source,str_des, 0)
if ulng_result<>0 then
messagebox("OK","拷贝文件成功!")
end if
方法二:
①先做一批处理文件lag.bat:
copy c:/lag.txt c:/tmp/lll.txt
②在程序中调用此批处理文件:
run("lag.bat")