Board index » cppbuilder » CopyFile() to a network drive doesn't work

CopyFile() to a network drive doesn't work


2004-08-29 09:16:50 PM
cppbuilder47
Hi,
I'm trying to copy a file from my local harddisk to a
network drive and i can't get it to work using CopyFile.
Anyone know how to do that?
Thanks,
Dave
 
 

Re:CopyFile() to a network drive doesn't work

Quote
I'm trying to copy a file from my local harddisk to a
network drive and i can't get it to work using CopyFile.
Please show the code which fails to copy the file.
In the meantime check if the destination folder have some
special attributes like read-only or similar, or just try to copy
any file with Explorer to the destination drive/folder to check
the accessibility.
Best regards,
Vladimir Stefanovic
 

Re:CopyFile() to a network drive doesn't work

On Sun, 29 Aug 2004 20:32:46 +0200, Vladimir Stefanovic wrote:
Quote
>I'm trying to copy a file from my local harddisk to a
>network drive and i can't get it to work using CopyFile.

Please show the code which fails to copy the file.

In the meantime check if the destination folder have some
special attributes like read-only or similar, or just try to copy
any file with Explorer to the destination drive/folder to check
the accessibility.


Best regards,
Vladimir Stefanovic
Dear Vladimir,
here's a sample
AnsiString Source, Destination;
CopyFile(Source.c_str(), Destination.c_str(), true);
Try it on local disk just fine but with a network drive it fails,
I tried CopyFileEx() too and won't work either,
Thanks
Dave
 

{smallsort}

Re:CopyFile() to a network drive doesn't work

Write the two AnsiStrings to the screen and check that they are valid
paths and file names. It could be something as simple as the lack of
doubled backslashes.
Check if the network drive permissions allow the copy as Mr Stefanovic
mentioned. Try doing a manual copy of a file from the command line to
the network drive and then checking the existence and size of the
destination file.
Call SetLastError(0) prior to the call and then see what the error
indicated by a call to GetLastError afterwards indicates.
. Ed
Quote
Dave wrote in message
news:1uouidjxeah21$.1gkj66tto1amd$ XXXX@XXXXX.COM ...

>>I'm trying to copy a file from my local harddisk to a
>>network drive and i can't get it to work using CopyFile.
>
>Please show the code which fails to copy the file.
>
>In the meantime check if the destination folder have some
>special attributes like read-only or similar, or just try to copy
>any file with Explorer to the destination drive/folder to check
>the accessibility.

AnsiString Source, Destination;

CopyFile(Source.c_str(), Destination.c_str(), true);

Try it on local disk just fine but with a network drive it fails,
I tried CopyFileEx() too and won't work either,