LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

FileExists and network location

Hi,

 

Happiness in programming is shorted lived, as least at my level of still learning with every new project.

 

I have used FileExists() to see if a directory is local on the PC, works as it says on the tin, happy man, the problem is when it comes to a network drive.

 

The network location is \\\\node1\\Prod_Test\\TestDataSource\\Rel\\Test_Folder\\

 

This will not find the Test_Folder even without the “\\” at the end.

 

Also CNVFolderExists (Network_Folder,Test_Folder_01, &Net_Exists); will not work with

sprintf(Network_Folder," \\\\node1\\Prod_Test\\TestDataSource\\Rel");

and Test_Folder_01,\\Test_Folder\\.

 

I have tried searching but nothing is jumping out at me as to what might be going wrong.

 

I have no problem copying the directory from the network location to a subdirectory on my PC or from the PC to the network.

 

Can anyone offer assistance?

 

I have CVI 2012 and Windows XP.

 

Thanks

Simon

 

0 Kudos
Message 1 of 6
(3,449 Views)

Happiness in programming is shorted lived, as least at my level of still learning with every new project.


Hello Simon,

 

your sentence made me smile, but the other way round is also true Smiley Wink It is not so difficult to reach the next sense of achievement...

 

Concerning your issue: I am not using FileExists from the Programmers Toolbox, but reading the help of this command reveals that the pathname of a file is not an absolute pathname...

 

I am using the function GetFileInfo () instead to see if a file exists, including files on the network, and so far I was happy with it...

 

(May be I should add that I have mapped the network drive, I don't know if this makes a difference)

0 Kudos
Message 2 of 6
(3,446 Views)

Wolfgang,

 

Thanks for that, unfortunately I had no joy as I will never know what files are in a directory I will be looking at, as the directory will also be dynamic.

 

I did try in for a folder on the network but with no joy on just a directory but did work for a file I do know is there

Good:

File_Pres = GetFileInfo ("\\\\node1\\Prod_Test\\TestDataSource\\Rel\\ADC004\\adcver.log", &Net_Exists);

 

Both the following returned 0,

File_Pres = GetFileInfo ("\\node1\\Prod_Test\\TestDataSource\\Rel\\ADC004\\", &Net_Exists);

 

File_Pres = GetFileInfo ("\\node1\\Prod_Test\\TestDataSource\\Rel\\ADC004", &Net_Exists);

 

If I put ("\\\\node1..... the two commands above will give non-fatal run-time errors.

 

Thanks

Simon

0 Kudos
Message 3 of 6
(3,440 Views)

Oh, I am sorry, I didn't pay attention that you were looking for a directory and not a file.

 

Now I have tried another approach, and it woks for me:

 

 result = GetFirstFile ( "n:\\xhr",0,0,0,0,0,1,new_name);

 

n is my network drive, xhr an existing folder. The result is 0 (that is, it does exist). If I search for "n:\\xhr23" instead, the result is -1, i.e., it does not exist which is also correct. 

Message 4 of 6
(3,434 Views)

Wolfgang,

 

Thank you.

 

It would appear the following will do the job

 

sprintf(Network_Folder,"\\\\node1\\Prod_Test\\TestDataSource\\Rel\\%s",Test_Folder);

File_Pres = GetFirstFile (Network_Folder,0,0,0,0,0,1,new_name);

            if (File_Pres != 0)

                        sprintf (message, "Folder %s is not found on the network.",Test_Folder);

            else

                        sprintf (message, "Folder %s has been found on the network.",new_name);

 

            MessagePopup ("Ping", message);

 

No need for a mapped drive as node1 is already known to the PC.

 

Again Thanks

Simon

0 Kudos
Message 5 of 6
(3,427 Views)

Ah, I am really pleased!

0 Kudos
Message 6 of 6
(3,424 Views)