Rick wrote:
> Hi all,
>
> How can I check to see if a file exists under the Windows OS? Something like:
>
> if (!file_exists("c:\dir\file.ext"))
> {do_something}
> else
> {do_something_else}
>
> What if the path is a directory?
>
> if (!file_exists("c:\dir"))
> {do_something}
> else
> {do_something_else}
>
> ~Rick
The closest thing to "Standard" that you'll find is the POSIX function
stat(). (Google 'man stat').
The Windows-specific API is GetFileAttributes(). Read the MSDN Library
description carefully. It accepts directory names as well! It also
behaves differently for drive roots (i.e. will fail to work on most/all
versions of Windows).
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/