cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

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.
0 kudos
Mensaje 1 de 7
5.153 Vistas

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
0 kudos
Mensaje 2 de 7
5.140 Vistas
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 ?


0 kudos
Mensaje 3 de 7
5.114 Vistas
My problem is not resolved.

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

Thanks.
0 kudos
Mensaje 4 de 7
5.101 Vistas

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
0 kudos
Mensaje 5 de 7
5.091 Vistas

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,

0 kudos
Mensaje 6 de 7
5.067 Vistas
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.




0 kudos
Mensaje 7 de 7
5.062 Vistas