Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Tue, 12 Feb 2008 11:24:10 +0200,    group: microsoft.public.platformsdk.shell        back       


Testing directory existence   
Hi,

How to test if a directory exists? Which Win32 function should be used?

Thanks in advance...
date: Tue, 12 Feb 2008 11:24:10 +0200   author:   K?r?at

Re: Testing directory existence   
>How to test if a directory exists? Which Win32 function should be used?

You could try using GetFileAttributes, but generally the problem with
testing if something exists is that it may no longer exist when you
come to do the real operation - so you always have to cater for later
failure, which effectively makes the test for existence partly
redundant.

Dave
date: Tue, 12 Feb 2008 10:04:32 +0000   author:   David Lowndes lid

Re: Testing directory existence   
On Feb 12, 1:24 am, "Kürþat"  wrote:
> Hi,
>
> How to test if a directory exists? Which Win32 function should be used?
>
> Thanks in advance...


Hi,

You can use the following APIs to verify that a path is a valid
directory:

	PathIsDirectory()

	PathIsDirectoryEmpty()

http://msdn2.microsoft.com/en-us/library/bb773621(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/bb773623(VS.85).aspx

Kellie.
date: Tue, 12 Feb 2008 12:10:55 -0800 (PST)   author:   Kellie Fitton

Re: Testing directory existence   
Or, if you prefer not to use shlwapi, which is available only with Internet 
Explorer 4.0 or higher (including Windows 2000 or higher), you can use 
GetFileAttributes and look for FILE_ATTRIBUTE_DIRECTORY:

http://msdn2.microsoft.com/en-us/library/aa364944.aspx

This page says it requires Windows 2000 or higher, but it's wrong! I will 
provide feedback asking for it to be corrected.

Paul

"Kellie Fitton"  wrote in message 
news:92918d09-b461-4c45-8e64-a70946a54a36@l32g2000hse.googlegroups.com...
On Feb 12, 1:24 am, "Kürþat"  wrote:
> Hi,
>
> How to test if a directory exists? Which Win32 function should be used?
>
> Thanks in advance...


Hi,

You can use the following APIs to verify that a path is a valid
directory:

PathIsDirectory()

PathIsDirectoryEmpty()

http://msdn2.microsoft.com/en-us/library/bb773621(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/bb773623(VS.85).aspx

Kellie.
date: Tue, 12 Feb 2008 15:47:55 -0500   author:   Paul Baker [MVP, Windows - SDK] am

Re: Testing directory existence   
... but be careful - if the file/directory of that path does not 
exist, the FILE_ATTRIBUTE_DIRECTORY flag will be set (as the return 
value is INVALID_FILE_ATTRIBUTES, which is "-1"). So there's first the 
need to check for INVALID_FILE_ATTRIBUTES return value.



Christian



> Or, if you prefer not to use shlwapi, which is available only with 
> Internet
> Explorer 4.0 or higher (including Windows 2000 or higher), you can 
> use
> GetFileAttributes and look for FILE_ATTRIBUTE_DIRECTORY:
>
> http://msdn2.microsoft.com/en-us/library/aa364944.aspx
>
> This page says it requires Windows 2000 or higher, but it's wrong! I 
> will
> provide feedback asking for it to be corrected.
>
> Paul
>
> "Kellie Fitton"  wrote in message
> news:92918d09-b461-4c45-8e64-a70946a54a36@l32g2000hse.googlegroups.com...
> On Feb 12, 1:24 am, "Kürþat"  wrote:
>> Hi,
>>
>> How to test if a directory exists? Which Win32 function should be 
>> used?
>>
>> Thanks in advance...
>
>
> Hi,
>
> You can use the following APIs to verify that a path is a valid
> directory:
>
> PathIsDirectory()
>
> PathIsDirectoryEmpty()
>
> http://msdn2.microsoft.com/en-us/library/bb773621(VS.85).aspx
>
> http://msdn2.microsoft.com/en-us/library/bb773623(VS.85).aspx
>
> Kellie.
>
>
date: Wed, 13 Feb 2008 08:36:43 +0100   author:   Christian Kaiser

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us