Home > Archive > Programming with dBASE > December 2005 > Directory Exists Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Directory Exists Question
Jerry

2005-12-07, 3:24 am

Hello,

I'm aware of the VALIDDRIVE() and also the FILE() (existence of a file)
Commands but I need to find out if a Directory exists so that if it doesn't
exist, I can create it with the MD Command.


Thanks,
Jerry Rivenbark


Roland Wingerter

2005-12-07, 3:24 am

Jerry wrote

>
> I'm aware of the VALIDDRIVE() and also the FILE() (existence of a file)
> Commands but I need to find out if a Directory exists so that if it
> doesn't exist, I can create it with the MD Command.

--------
Look in the dUFLP. There are two solutions named isDir().

Roland



Denis Finch

2005-12-07, 11:23 am

I use this:

if TYPE("CreateDirectory") # "FP"
extern clogical CreateDirectory(cstr
ing, cptr) kernel32 ;
from "CreateDirectoryA"
endif

function CheckDirectory
local c
c = set("directory")
if CreateDirectory(c + "\Data", null)
else
// if return is false then assume directory already exist
endif

What I like about this API is that it returns true or false.

"Jerry" <RivenbarkJerry@aol.com> wrote in message
news:SzJFont%23FHA.1020@news-server...
> Hello,
>
> I'm aware of the VALIDDRIVE() and also the FILE() (existence of a file)
> Commands but I need to find out if a Directory exists so that if it

doesn't
> exist, I can create it with the MD Command.
>
>
> Thanks,
> Jerry Rivenbark
>
>



Les Shewchuk

2005-12-07, 1:23 pm

Look in the help under the Try...Catch

The second example does the same job...Backwards.

It tries to MD the folder.
If the folder doesn't exist, it is Created
If the folder already exists, the command throws an error, but the CATCH
does nothing with it.

Kinda cool really.

Les Shewchuk

"Jerry" <RivenbarkJerry@aol.com> wrote in message
news:SzJFont%23FHA.1020@news-server...
> Hello,
>
> I'm aware of the VALIDDRIVE() and also the FILE() (existence of a file)
> Commands but I need to find out if a Directory exists so that if it
> doesn't exist, I can create it with the MD Command.
>
>
> Thanks,
> Jerry Rivenbark
>



Sharlene England

2005-12-07, 8:24 pm

This is what I use:

cDir = "k:\data\" + whatdir + "\"
if empty(funique(cDir))

md k:\data\&whatdir
endif


Jerry

2005-12-09, 3:23 am

Problem solved - thanks for the ideas submitted. I knew about the example
in the help file but had forgotten about the information linked to DULP.

Thanks,
Jerry

"Jerry" <RivenbarkJerry@aol.com> wrote in message
news:SzJFont%23FHA.1020@news-server...
> Hello,
>
> I'm aware of the VALIDDRIVE() and also the FILE() (existence of a file)
> Commands but I need to find out if a Directory exists so that if it
> doesn't exist, I can create it with the MD Command.
>
>
> Thanks,
> Jerry Rivenbark
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com