Subject |
Re: Directory verification |
From |
Ken Mayer <dbase@nospam.goldenstag.net> |
Date |
Sun, 16 Apr 2017 11:13:17 -0700 |
Newsgroups |
dbase.getting-started |
On 4/16/2017 9:52 AM, Heinz Kesting wrote:
> Hi Charlie,
>> Is it possible to verify if directories on a computer outside dbase
>> exist?
>>
>
> More on this. While VALIDDRIVE() only checks if the specified DRIVE is
> valid or present, you can use the following TRY construct to test for an
> existing directory:
>
> private cCurDir // PRIVATE is important here
> cCurDir = set("DIRECTORY") // save current dir
> try
> cd "D:\folder1\folder2\folder3" // example folder
> set directory to &cDir. // switch back to previous dir
> catch (exception e) // catch error if not existing
> msgbox("No such folder")
> endtry
>
> If the command CD ... is successful, the directory is actually changed,
> but if you don't want this to happen right now, and only need to know if
> the folder exists, then you may want to switch back to the folder you
> were working in before. That's why the storage of the current folder at
> the beginning.
>
> If you need more functions for working with folders, you could use the
> Windows FileSystemObject. This would provide functions like
> FolderExists(), CreateExists() and DeleteFolder()
There is also functionality in the dUFLP (IsDir() ...) that will do this.
Ken
--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
|
|