Board index » delphi » Determining whether Directory Exists

Determining whether Directory Exists

Is there a way to determine whether or not a directory already exists? I
guess I'm looking for something similar to the FileExists function.
Thanks in Advance.
Brad

 

Re:Determining whether Directory Exists


In article <19970511013100.VAA28...@ladder01.news.aol.com>,

Quote
dbradda...@aol.com (DBradDavis) wrote:> > Is there a way to determine

whether or not a directory already exists? I> guess I'm looking for
something similar to the FileExists function.> Thanks in Advance.>
BradMaybe the following would help, ugh:-)?  Unit  FileCtrl
DirectoryExists determines whether a specified directory exists.
<b>function DirectoryExists(Name: string):
Boolean;</b>---------------Hope That HelpsNick Sklobovsky,Obninsk,
RussiaNSklobov...@usa.net

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

Re:Determining whether Directory Exists


Quote
DBradDavis wrote:

> Is there a way to determine whether or not a directory already exists? I
> guess I'm looking for something similar to the FileExists function.
> Thanks in Advance.
> Brad

        I wasn't sure about this just now - here's what I did: I found
delphi.hlp in Windows Explorer. I double-clicked on it. Then I typed
"dir" (without the quotes). At this point I could see a topic "directories",
with a subtopic "testing existence".

        Then I gave up - Delphi's great but the documentation sucks.
Maybe someone else knows the name of the DirectoryExists function.

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Re:Determining whether Directory Exists


DBradDavis <dbradda...@aol.com> escribi en artculo
<19970511013100.VAA28...@ladder01.news.aol.com>...

Quote
> Is there a way to determine whether or not a directory already exists? I
> guess I'm looking for something similar to the FileExists function.
> Thanks in Advance.
> Brad

Unit FileCtrl

function DirectoryExists(Name: string): Boolean;

The DirectoryExists function determines whether the directory specified as
the value of the Name parameter exists. If the directory exists, the
function returns True. If the directory does not exist, the function
returns False.
If only a directory name is entered as the value of Name, DirectoryExists
searches for the directory within the current directory. If a full path
name is entered, DirectoryExists searches for the directory along the
designated path.

Re:Determining whether Directory Exists


In article <19970511013100.VAA28...@ladder01.news.aol.com>, dbradda...@aol.com
says...

Quote

>Is there a way to determine whether or not a directory already exists? I
>guess I'm looking for something similar to the FileExists function.
>Thanks in Advance.
>Brad

The following from Delphi 2.01 help file.

John XU
Big Creek Software
Des Moines, Iowa
joh...@bigcreek.com

---------------------------------------------------------

Unit

FileCtrl

Declaration

function DirectoryExists(Name: string): Boolean;

Description

The DirectoryExists function determines whether the directory specified as the
value of the Name parameter exists. If the directory exists, the function returns
True. If the directory does not exist, the function returns False.
If only a directory name is entered as the value of Name, DirectoryExists searches
for the directory within the current directory. If a full path name is entered,
DirectoryExists searches for the directory along the designated path.
Example

This example uses an edit box, a label, and a button on a form. When the user
enters a directory name in the edit box and clicks the button, whether or not the
directory exists is reported in the caption of the label:

procedure TForm1.Button1Click(Sender: TObject);
begin
  if DirectoryExists(Edit1.Text) then
    Label1.Caption := Edit1.Text + ' exists'
  else
    Label1.Caption := Edit1.Text + ' does not exist';
end;

Re:Determining whether Directory Exists


Quote
DBradDavis wrote:

> Is there a way to determine whether or not a directory already exists? I
> guess I'm looking for something similar to the FileExists function.
> Thanks in Advance.
> Brad

of course, you are right! There is! Try the following:
 DirectoryExists(str)

--
 with regards
              P.Plass
 ______________________________________________________________
|                        |                                     |
| WHZ(FH), FG Tech.Mech. | Phone: ++49-0375-536-1178           |
|                        | E-Mail: peter.pl...@fh-zwickau.de   |
| privat:                |                                     |
| Dr.-Ing. Peter Plass   | Phone: ++49-0375-661489             |
| Alter Marktsteig 34    |                                     |
| D-08149 Vielau         | URL:  PTasks5-Beta ...              |
| BR Deutschland/Germany | http://www.fh-zwickau.de/~pp/tm.htm |
|________________________|_____________________________________|
  PTasks4.30: http://www.fh-zwickau.de/~pp/software/ptasks.zip

Re:Determining whether Directory Exists


Quote
DBradDavis wrote:

> Is there a way to determine whether or not a directory already exists? I
> guess I'm looking for something similar to the FileExists function.
> Thanks in Advance.
> Brad

The FindFirst function finds files AND Directories.

I THINK it uses DOS names on Win 95... I am not sure... Check the docs.

--
--------------------------------------------
In theory, theory and practice are the same.
In practice, they are not.
--------------------------------------------
Bryan Valencia
Software Services - Making Windows Scream
WWW   : www.invsn.com/softserv/
email : bry...@thevision.net
--------------------------------------------

Other Threads