I am not sure if this system call is avaliable in windows programming:
         #include <unistd.h>
         int access(const char *pathname, int mode);
Regards,
Prakash
Thomas Hruska <[EMAIL PROTECTED]> wrote:
          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/



         

       
---------------------------------
Boardwalk for $500? In 2007? Ha! 
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.

[Non-text portions of this message have been removed]

Reply via email to