Jump to content

How to distinguish between files and directories?


 Share

Recommended Posts

Gentlemen, I have yet another one of those odd problems that only seem to affect me. :-)

I'm writing a program that allows users to pass filenames to it. However, I need to verify that it 1) exists, and 2) is actually a file and not a directory. FileExists() will take care of condition 1), but I haven't been able to figure out how to handle condition 2). Any suggestions?

Thanks.

Oh, I just thought of a possible useful feature. How about modifying FileExists() to return 0 if the passed filename does not exists, 1 if it does and it's a file, or 2 if it does and it's a directory? This would offer a very simple solution for anyone that needs to distinguise between the two. Also, since either 1 or 2 will both be considered TRUE, it shouldn't have any unintentional side-effects (unless someone hard-coded the 1).

Of course, that doesn't help me here. :-) So, any suggestions? Again, thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...