Howdy, Stranger!

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

Categories

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.

Some questions about file copying

I'm using the API function to copy a file, but the problem is that it doesn't copy the file at all.

The goal is to create a folder (sourcecode completed), then copy a file supplied in the same directory as the exe resides in to the same parent dir that the folder was created in and rename the file to the folder adding an .info extension.

Yes I've tried as hard as I can to do this, but nothing seams to happen.

So any help would be highly aprechiated.

Here is the form paint procedure that copies the directory if the curdir string is empty:

[code]
if curdir = '' then curdir := form2.DirectoryListBox1.Directory;
[/code]

This is the copy code I'm using:

[code]
Copyfile(pchar(Curdir+'Empty.info'),pchar(form2.directorylistbox1.directory+drawer.text));
[/code]

Should copy the file, but either it generates a file not found or copies the files somewhere I don't have a clue about.

Comments

  • zibadianzibadian Posts: 6,349Member
    : I'm using the API function to copy a file, but the problem is that it doesn't copy the file at all.
    :
    : The goal is to create a folder (sourcecode completed), then copy a file supplied in the same directory as the exe resides in to the same parent dir that the folder was created in and rename the file to the folder adding an .info extension.
    :
    : Yes I've tried as hard as I can to do this, but nothing seams to happen.
    :
    : So any help would be highly aprechiated.
    :
    : Here is the form paint procedure that copies the directory if the curdir string is empty:
    :
    : [code]
    : if curdir = '' then curdir := form2.DirectoryListBox1.Directory;
    : [/code]
    :
    : This is the copy code I'm using:
    :
    : [code]
    : Copyfile(pchar(Curdir+'Empty.info'),pchar(form2.directorylistbox1.directory+drawer.text));
    : [/code]
    :
    : Should copy the file, but either it generates a file not found or copies the files somewhere I don't have a clue about.
    :
    Sounds like the values for the CurDir and form2.directorylistbox1.directory are not what you expect them to be. Check wether or not they contain trailing backslashes, that they don't contain "weird" characters, which are illegal in file paths, etc.
  • jobromediajobromedia Posts: 168Member
    : : I'm using the API function to copy a file, but the problem is that it doesn't copy the file at all.
    : :
    : : The goal is to create a folder (sourcecode completed), then copy a file supplied in the same directory as the exe resides in to the same parent dir that the folder was created in and rename the file to the folder adding an .info extension.
    : :
    : : Yes I've tried as hard as I can to do this, but nothing seams to happen.
    : :
    : : So any help would be highly aprechiated.
    : :
    : : Here is the form paint procedure that copies the directory if the curdir string is empty:
    : :
    : : [code]
    : : if curdir = '' then curdir := form2.DirectoryListBox1.Directory;
    : : [/code]
    : :
    : : This is the copy code I'm using:
    : :
    : : [code]
    : : Copyfile(pchar(Curdir+'Empty.info'),pchar(form2.directorylistbox1.directory+drawer.text));
    : : [/code]
    : :
    : : Should copy the file, but either it generates a file not found or copies the files somewhere I don't have a clue about.
    : :
    : Sounds like the values for the CurDir and form2.directorylistbox1.directory are not what you expect them to be. Check wether or not they contain trailing backslashes, that they don't contain "weird" characters, which are illegal in file paths, etc.
    :
    I skipped the curdir parameter and added an extra directorylistbox to copy the directory from. Copy process completed.

    Thanks for your help!
Sign In or Register to comment.