To Find a folder

I need to know if exists a folder I want do the following process: *If Exists(c:\myfolder) then export file to my folder else export file to c:* Do you know how can I do this? Thank you

You could check for an existing file in that folder, e.g.

IF EXISTS('C:\MyFolder\Checkfile.txt') THEN
  // do something
ELSE
  // do something else

or you could try to create a new file, e.g.

IF TestFile.CREATE('C:\MyFolder\Checkfile.txt') THEN
  // do something
ELSE
  // do something else

Alternativly you could also try to copy a file to that folder, e.g.

IF COPY('C:\Checkfile.txt','C:\MyFolder\Checkfile.txt') THEN
  // do something
ELSE
  // do something else

Well, of course there could be other reasons if these methods fail … Regards, Jörg

Thanks Jörg for your examples, but… there is a problem, the folder where I want to do it, can be empty. I can create a checkfile.txt in my computer but this process must be execute for some people of the same company and I can’t create that textfile wherever. So I need another solution, if it’s possible, of course. Thanks

You can use the virtual tabel 2000000022 File. Var FilePath Text 30 Var FolderName Test 30 Var FileRec Record File FileRec.SETRANGE(Path,FilePath); FileRec.SETRANGE(“Is a file”,FALSE); // Only folders FileRec.SETRANGE(Name,FolderName); IF FileRec.FIND(’-’) THEN …

Thank you very much Claus, your solution it’s ok!! but now I have another problem… if I use your solution code on SQL Navision it doesn’t works, it never finds the folder… Do you know why?

use a automation variable of FileSystemObject

To check whether a directory exists, do like this: IF FILE.OPEN(‘c:\mydirectory\nul’) THEN “nul” is an “existing file” in every directory.

You could use table 2000000022 File Set the filter on path to C: Filter on Name to ‘myfolder’ and test if the record exists. Create a form using table 2000000022 and put a filter on path to see how it works. Paul Baxter