2009R2 classic| how to check if directory exists in network

AkvileAkvile Member Posts: 3
Hello,
I have a problem, when running codeunit from classic client it checks if in the directory (which is in the network for example \\vision3new\data\) is some files in File system table.
All is good, when network is running, but sometimes when network is down for some reason I get a message
"The network path cannot be found.
This message refers to the file \\vision3new\data\*.*.
The network server may be down, or the path may be invalid."
But I want not to get message, but just write it in the integration log table because now it won't write it in the log.
So I want the error to be recorded in the log table and the work keeps going until network will start (because it could be down just for a couple of minutes).
I tried with EXISTS(EqSetup."Incoming File Directory"+ 'nul'); but it just write in log table that "The operating system cannot find the file \\vision3new\data\nul .
Verify that the drive, directory, and file names are correct." even thought network is running and not down.

I will wait for some thoughts.
Regards,
Akvilė

Answers

  • ErictPErictP Member Posts: 164
    I used the following code for a batch to import files:
    var 
    Name	DataType	Subtype	Length
    Directory	Record	File	
    Dir	text 1024
    
    
    Dir := Setup."Incoming File Path"
    SELECTLATESTVERSION;
    Directory.SETRANGE(Path,ENVIRON('temp'));
    IF hDirectory.FINDFIRST THEN;             //to be sure that the data is refreshed
    
    Directory.SETRANGE(Path,Dir);
    Directory.SETFILTER(Name, '%1', '*.@XML');
    Directory.SETRANGE("Is a file",TRUE);
    IF Directory.FINDSET(FALSE,FALSE) THEN BEGIN
      REPEAT
    	  //Do your thing  with the found file
    	UNTIL Directory.NEXT() is 0;
    
  • RockWithNAVRockWithNAV Member Posts: 1,139
    Did you tried using from File Management Codeunit - ClientDirectoryExists/ServerDirectoryExists ?
Sign In or Register to comment.