cancel
Showing results for 
Search instead for 
Did you mean: 

CopyFile and RenameFile over network

NicoP
Member

CopyFile and RenameFile over network

LabWindows 7.1.1, Windows XP

Hi,

I have a problem using the CopyFile and RenameFile functions when one of the filename specifies a remote file.
A library function error occurs (-5) with both functions.

For the filenames I pass something liket that : "\\192.168.14.10\DATA\data.txt"
The source file with my local IP adress, and for the other one, the remote IP adress.
"DATA" is a shared directory with complete access.

With those filenames, when I test the remote file with FileExists, it's OK.
Moreover, I can delete the remote file.

So, what is wrong ?
Is there any limitation with these functions ?


Thanks.
6 REPLIES 6
Wendy L
NI Employee (retired)

Re: CopyFile and RenameFile over network

Message contains a hyperlink

Hello NicoP,

In order to use the CopyFile to save to a network location, you can first map that location to a drive on your machine (My Computer >> Tools >> Map Network Drive).  Then in the CopyFile function you would pass the mapped drive as one of the parameters, and it should successfully copy you file over to the remote location.

Before:

CopyFile("c:\\test.txt", "\\\remote\\test.txt"); returns a -5 error.

After

CopyFile("c:\\test.txt", "y:\\test.txt"); where Y: is mapped to \\remote.

 

Hope that helps.

 

Wendy L
LabWindows/CVI Developer Newsletter
NicoP
Member

Re: CopyFile and RenameFile over network

Thank you Wendy.

But I've just tested your solution and the results are still the same (-5).

An other thing :
I want to call CopyFile("C:\\temp\\test.TXT", "v:\\test.TMP);

If I create manually the "v:\\test.TMP", CopyFile gives a 0 result.
So, I think CopyFile tests the th existence of "v:\\test.TMP" when it exists, and because this file is there, the result is 0.
So, CopyFile can correctly access my "V:\\", but can't create a file.

Why ?

Thanks for your ideas, suggestions, comments ...

Do you need an example of my code ?


NicoP
Member

Re: CopyFile and RenameFile over network

My problem is not resolved.

Please, could you take a look at my last post below ?

Thanks.
Wendy L
NI Employee (retired)

Re: CopyFile and RenameFile over network

Hello NicoP,

I ran the following code on my machine, and it worked as expected:

#include <utility.h>
#include <cvirte.h>

int main (int argc, char *argv[])
{
 if (InitCVIRTE (0, argv, 0) == 0)
  return -1;    /* out of memory */
 
 CopyFile ("c:\\test.txt", "z:\\test.txt");
 return 0;
}

I would double check the write permissions on your network drive to see if it allows files to be created remotely.

Thanks.

Wendy L
LabWindows/CVI Developer Newsletter
Benjamin_C
Active Participant

Re: CopyFile and RenameFile over network

Hello,

I agree with Wendy. I made some tests and everything works as expected. I suggest you to test with another network ressource and with another PC.

Regards,

NicoP
Member

Re: CopyFile and RenameFile over network

Hello,

Excuse me, I didn't post my new results.

Of course, wendy were right.

I have to share the directory with "Modify permission", and also to define the good permissions to the right user.
My problems come from that last point.

Now, it works fine with most OS (from XP Pro to XP Pro, NT 4.0 workstation, 2000 Pro, 2000 server).

But you now what, CopyFile still gives me the same -5 with 98 SE.




Thanks for all.