copyFile("my_image.jpg","duplicate_image.jpg") end
function copyFile(fileName$, newName$) // open the two files sourceFile =OpenToRead(fileName$) destFile =OpenToWrite(newName$)
// while we are not at the end of the source file whileFileEOF(sourceFile)=0 // write the next byte in the source file to the dest file // by going through it byte by byte, this function will be able to copy any file, regardless of format WriteByte(destFile,ReadByte(sourceFile)) endwhile
// close the files CloseFile(sourceFile) CloseFile(destFile) endfunction
Help make AGK better by submitting an example for this command! (All examples are subject to approval)