Sign in to follow this  

FindFirstFile broke on vista?

This topic is 3374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have code using FindFirstFile. I am positive it worked fine on XP. On vista it does not work. I then thought maybe i can only enumerate files in user profile so i decided to enumerator my desktop. No luck either. The string i use is c:/my/path/desktop/*, i tried backslashes too, no luck. Is there anything i need to do to be allowed to use FindFirstFile on vista?

Share this post


Link to post
Share on other sites
Assuming it works like _findfirst(), then you may need to tell it to find '*.*', not just '*'. That's just a guess though, since, as the other guys mentioned, we need a little more information before we can tell what the real problem is.

Share this post


Link to post
Share on other sites
Firstly it does need to be blackslashes, not forward-slashes. Then secondly, because the backslash is the escape character within strings in C & C++, you need to have two of them for each backslash you want in the string.[smile]

If that wasn't the problem, please post actual code.

Share this post


Link to post
Share on other sites
i figured it out. I accidentally left the project in unicode mode. I was passing a char* and i received no error or warning :x and i didnt typecast either.

How could i not get an error like that :X. What tipped me off was GetCurrentDirectory was only giving me the letter 't' and that happened to be the drive letter of my dev partition.

Share this post


Link to post
Share on other sites
Quote:
Original post by iMalc
Firstly it does need to be blackslashes, not forward-slashes.

Are you sure about this or is this a Vista only requirement? The docs show no such requirement and I have been able to use forward slashes on a none Vista OS in the past.

Share this post


Link to post
Share on other sites
Quote:
Original post by dmail
Quote:
Original post by iMalc
Firstly it does need to be blackslashes, not forward-slashes.

Are you sure about this or is this a Vista only requirement? The docs show no such requirement and I have been able to use forward slashes on a none Vista OS in the past.
It's not listed as a requirement in the documentation for FindFirstFile because it's described in the guidelines for Naming a File or Directory in Windows, which FindFirstFile naturally relies on. Note that (as mentioned in the linked document) "File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections."

Share this post


Link to post
Share on other sites

This topic is 3374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this