Board index » delphi » Help with files/dirs

Help with files/dirs

I need to be able to determine
if a given string is just a
directory e.g. 'c:\windows'
or a directory and filename
e.g. 'c:\windows\readme.txt'
to give each a different icon
in a listview.

Does anyone know how I may do this?

 

Re:Help with files/dirs


DirectoryExists (string)
FileExists(string)

How are you getting the list?  If you're using FindFirst, just check the
TSearchRec attributes for the Directory attribute

Quote
"daverich" <daver...@iprimus.com.au> wrote in message

news:3d397c7d_1@news.iprimus.com.au...
Quote
> I need to be able to determine
> if a given string is just a
> directory e.g. 'c:\windows'
> or a directory and filename
> e.g. 'c:\windows\readme.txt'
> to give each a different icon
> in a listview.

> Does anyone know how I may do this?

Re:Help with files/dirs


In article <3d397c7...@news.iprimus.com.au>, daverich <daver...@iprimus.com.au>
writes:

Quote
>I need to be able to determine
>if a given string is just a
>directory e.g. 'c:\windows'
>or a directory and filename
>e.g. 'c:\windows\readme.txt'
>to give each a different icon
>in a listview.

>Does anyone know how I may do this?

FileIsDirectory := (FileGetAttr(MyFileName) and faDirectory <> 0);

FileGetAttr() is in SysUtils.

Alan Lloyd
alangll...@aol.com

Re:Help with files/dirs


Quote
"daverich" <daver...@iprimus.com.au> wrote in message

news:3d397c7d_1@news.iprimus.com.au...

Quote
> I need to be able to determine
> if a given string is just a
> directory e.g. 'c:\windows'
> or a directory and filename
> e.g. 'c:\windows\readme.txt'
> to give each a different icon
> in a listview.

> Does anyone know how I may do this?

In addition to the other suggestions, you can use shGetFileInfo to retrieve
the icon used by Win Explorer. IIRC this includes the folder icon when
appropriate.

Other Threads