en@frrom
24th February 2011, 15:38
Hello fellows,

I have a simple requirement: checking whether a local directory path the user entered on a form, exists.

Strange enough I have not found any sufficient way to do this. The functions I tried so far:
- dir.open
- dir.present
- is_dir
None of them seem to work; I think they all work on server only.

I also tried create.local.directory (and then follow with remove.local.directory if return value <> -183) but I really don't like this mehtod, for I will be creating and removing directories on the client without notification! I also do not trust the function's return values.

I also searched the board but could not find any straight forward sufficient solution.

I also searched through dlls ttdllbw & ttdllfilehand, but did not find anything new.

Any ideas?

Thanks,
Eli Nager

mark_h
24th February 2011, 19:11
Is this to read a file or to write a file? Should the directory already exist? I really don't have a good solution, but we just try to put the file. If an error create the directory and put the file again. I doubt this is what you are looking for.

NPRao
24th February 2011, 20:51
You can try a direct DOS command -

IF [NOT] EXIST filename command ELSE command

For example,

@echo off
IF exist myDirName ( echo myDirName exists ) ELSE ( mkdir myDirName && echo myDirName created)

en@frrom
25th February 2011, 09:39
Mark, thanks for your input. I don't want to perform a check for writing a file to that directory. Rather, the user selects a directory on the form, and in the check.input of that field I just want to check whether the local directory exists. (In fact, afterwards I either put or read files from/to that directory, depending on the user's selection in a different field.

NpRao, thank you as well for your input. What do you mean with a direct DOS command, can I directly use DOS commands in the script? Or do you mean by using start.application.local / app.start?

george7a
25th February 2011, 10:14
I once solved this by copying a temp file to the local directory. If it succeeded then the directory is there (I delete the file). If not, I create the directory. It is very similar to what mark said.

Yes, you can run a DOS command through start.application.local / app.start