||
function copyfile(source,destination)
sourcefile = io.open(source,'r')
destinationfile = io.open(destination,'w')
for line in sourcefile:lines() do
destinationfile:write(line)
end
sourcefile:close()
destinationfile:close()
end
copyfile('C:/1.txt','C/2.txt')
将C盘下的1.txt文件复制一份到C盘下的2.txt文件中
对于二进制文件没有试过,不知是否把上面的
sourcefile = io.open(source,'r')
destinationfile = io.open(destination,'w')
改为
sourcefile = io.open(source,'rb')
destinationfile = io.open(destination,'wb')
就可以
有兴趣的可以试验一下
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-30 02:36
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社