Forum Discussion

sujathab's avatar
sujathab
Occasional Contributor
14 years ago

Replacing the file

Hi,



I have two files. One has been placed in the C:\ and other one is in D:\



My requirement is for each automation the file placed in the C:\ has to be replaced by D:\



Is it possible to do so?



Thanks in advance



Regards,

Sujatha B

4 Replies

  • Sujatha,


    You can use the aqFile.Copy method for this.

    Make sure that the last parameter is False. This will command the method to replace the file on C:\ --




    Call aqFile.Copy("D:\FileName.txt", "C:\FileName.txt", false)

  • sujathab's avatar
    sujathab
    Occasional Contributor
    Hi,



    Thanks for your suggestion.



    my requirement is i need to replaced the content of an xml file from C:\ to another xml file of the D:\



    Is this possible?





    Thanks in advance



    Regards,

    Sujatha B
  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    Hi Sujatha,



    File copying will eventually replace the content of the target file, wouldn't it?
  • Alexei,

    This is what I wanted to answer too :-)


    Sujatha,

    If you need to replace only some part of a file, you need to load the files to memory, extract the needed data from one file, then insert it into another file and save. The way you do this depends on the file contents. If you post here some sample contents of your files, we could find a solution.