CopyFile
CopyFile SourceFilename$, OuputFilename$
 
Parameters:

    SourceFilename$ = The Filename of the file you wish to copy
    OuputFilename$ = The Filename and output location of the copied file
Returns: NONE
 

      CopyFile will copy a file.



FACTS:


      * Before you use CopyFile always make sure that source filename exists. If you try and copy a file that doesn't exist, PlayBASIC will return a run time error.




Mini Tutorial:


      This example will create a blank file on the C: Drive called "TestFile.txt" , then copies it and displays the info about this file. both files are removed before the program ends.

  
; Create a variable for the Source files name
  SrcFilename$="C:\TestFile.txt"
  
; Create a variable for the output files name
  OutputFilename$="C:\TestFile_COPY.txt"
  
; Make the blank file, 100 bytes in size to copy
  MakeFile SrcFilename$,100
  
; Copy the File to
  CopyFile SrcFilename$,OutputFilename$
  
; display the info about the created file
  Print "File Name:"+OutputFilename$
  Print "File Exist:"+Str$(FileExist(OutputFilename$))
  Print "File Size:"+Str$(FileSize(OutputFilename$))
  
; now delete this file, as it's no use to use anymore
  DeleteFile SrcFilename$
  DeleteFile OutputFilename$
  
  
; Display the screen and wait for a key press
  Sync
  WaitKey
  
  


This example would output.

  
  File Name:C:\TestFile_Copied.txt
  File Exist:1
  File Size:100
  

 
Related Info: CurrentDir$ | DeleteFile | DriveList$ | FileExist | FolderExist | GetFileName$ | GetFolderName$ | MoveFile :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com