Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Still can't copy files :(

Well I'm in severe need of a working copy routine to copy 2 files from the current directory where the exe resides into another directory where one of the files are renamed.

The files needed to be copied is a file named .info and another file named enpty.info

for more info see www.winaminfo.all.at

The goal is this: The program creates a folder. then it copies the .info into the folder created and the empty.info is renamed to the directory just created and resides in the same directory as the created directory. Sounds complicated? It ain't that hard when it all comes around.

Comments

  • porodoroporodoro Posts: 230Member
    [b][red]This message was edited by porodoro at 2006-1-1 4:52:58[/red][/b][hr]
    i wrote this code. I hope it will help you.

    var File_:String;
    var File_2:string;
    var File_Newname:String;
    var File_2Newname:string;
    var Folder:String;
    var CurrentDir :string;
    var IF_exists_Cancel : boolean;
    begin
    IF_exists_Cancel:=false;
    currentDir:=
    ExtractFilePath((Application.ExeName));
    Folder:=currentDir+'MyFolder';
    //files to be copied
    //def name
    File_:=CurrentDir + 'Test.INFO';
    File_2:=CurrentDir + 'Test2.INFO';
    //rename them to:
    File_Newname:='Renamed1.info';
    File_2Newname:='Renamed2.info';

    //if not dir exists then create it!
    if (not directoryExists(Folder)) then
    begin
    mkdir(Folder);
    end;

    try
    //if already in use return exception )FILE 1
    copyfile(
    PCHAR(file_),
    pchar(Folder+''+File_Newname),
    IF_exists_Cancel);
    //if already in use return exception )FILE 2
    copyfile(
    PCHAR(file_2),
    pchar(Folder+''+File_2Newname),
    IF_exists_Cancel);
    except
    BEEP;
    MessageBOx(Handle,
    Pchar('File'+' ('+file_+' or '+file_2+') is already in use.Copy canceled'),
    pchar('IO Error'),mb_OK);
    end;

    //IF both exist return success
    if fileExists(Folder+''+File_Newname)
    AND
    fileExists(Folder+''+File_2Newname)
    THEN begin
    Messagedlg('Files copyed to :' +Folder +' ' +'Successfully!',mtInformation,[mbOK],-1);
    end;

    happy 2006!
  • jobromediajobromedia Posts: 168Member
    :
    : happy 2006!
    :
    Same to you!

    Thanks a bunch! Now the copying goes better. Still not good, but I can most likely sort that out myself.

Sign In or Register to comment.