Board index » delphi » Code to check existence of a folder

Code to check existence of a folder

Hi,

    Anyone here has the code that check for the existence of a folder? Can
you share the code with me. Thanks.

Regards,
Tan Tze Yong

 

Re:Code to check existence of a folder


DirectoryExists function

Determines whether a specified directory exists.

Unit
FileCtrl

Category
file management routines

function DirectoryExists(Name: string): Boolean;

Description
Call DirectoryExists to determine whether the directory specified by the
Name parameter exists. If the directory exists, the function returns True.
If the directory does not exist, the function returns False.

If a full path name is entered, DirectoryExists searches for the directory
along the designated path. Otherwise, the Name parameter is interpreted as a
relative path name from the current directory.

"Tan Tze Yong" <tytan1...@pacific.net.sg> wrote in message
news:9as7ri$hpu$1@newton.pacific.net.sg...

Quote
> Hi,

>     Anyone here has the code that check for the existence of a folder? Can
> you share the code with me. Thanks.

> Regards,
> Tan Tze Yong

Re:Code to check existence of a folder


In article <9as7ri$hp...@newton.pacific.net.sg>, tytan1...@pacific.net.sg
says...
Quote
> Hi,

>     Anyone here has the code that check for the existence of a folder? Can
> you share the code with me. Thanks.

> Regards,
> Tan Tze Yong

its a built in function to delphi :-
DirectoryExists(DirectoryPath:String):Boolean;

so you could do

if DirectoryExists('C:\Windows\') then ShowMessage('Found Windows
Folder');

Re:Code to check existence of a folder


In article <9as7ri$hp...@newton.pacific.net.sg>, "Tan Tze  Yong"

Quote
<tytan1...@pacific.net.sg> writes:
>    Anyone here has the code that check for the existence of a folder? Can
>you share the code with me. Thanks.

Folder used to be called Directory.

DirectoryExists(DirPath : string) : boolean;

  ... in Delphi.hlp

Alan Lloyd
alangll...@aol.com

Re:Code to check existence of a folder


{
########################################################################

  DirectoryExists is in FileCtrl which pulls in Forms & Dialogs

Quote
}

Function DirExists( Const Fle:String ):Boolean ;
  Var
  Q : Integer ;
  Begin
  Result := False ;
  Q := FileGetAttr( Fle ) ;
  If Q <> -1 Then
     If ( Q And 16 ) = 16 Then
        Result := True ;
End; {DirExists}

Another method is to look at the FileExists code

On Mon, 09 Apr 2001 12:24:46 GMT, Mattius

Quote
<mattinglis@blueyonder-=SPAMsuckS=-.co.uk> wrote:
>In article <9as7ri$hp...@newton.pacific.net.sg>, tytan1...@pacific.net.sg
>says...
>> Hi,

>>     Anyone here has the code that check for the existence of a folder? Can
>> you share the code with me. Thanks.

>> Regards,
>> Tan Tze Yong

>its a built in function to delphi :-
>DirectoryExists(DirectoryPath:String):Boolean;

>so you could do

>if DirectoryExists('C:\Windows\') then ShowMessage('Found Windows
>Folder');

Re:Code to check existence of a folder


Apart from using DirectoryExists, you could check for the file . (dot) in
the directory. This works because every directory contains this. (not
tested)

IByte

Tan Tze Yong <tytan1...@pacific.net.sg> wrote in message
news:9as7ri$hpu$1@newton.pacific.net.sg...

Quote
> Hi,

>     Anyone here has the code that check for the existence of a folder? Can
> you share the code with me. Thanks.

> Regards,
> Tan Tze Yong

Other Threads