怎样在PB中实现文件的拷贝与删除,可借助外部函数
可用API函数实现:
1、文件拷贝
函数声明:
FUNCTION boolean CopyFileA(ref string cfrom, ref string cto, boolean flag) LIBRARY "Kernel32.dll"
调用:
string ls_source, ls_des
boolean lb_flag, lb_rtn
lb_flag = false
ls_source = "c:\book.xls" //源文件
ls_des = "C:\tmp\111.xls" //目标文件
lb_rtn = CopyFileA(ls_source, ls_des, lb_flag)
MessageBox("文件拷贝", string(lb_rtn))
2、删除文件
函数声明:
FUNCTION boolean DeleteFileA(ref string filename) LIBRARY "Kernel32.dll"
调用:
string ls_file
boolean lb_rtn
ls_file = "C:\tmp\111.xls"
lb_rtn = DeleteFileA(ls_file)
MessageBox("文件删除", string(lb_rtn))
或者用PB本身的函数FileDelete()来删除文件。