FindFirstFile broke on vista?

Started by
7 comments, last by iMalc 15 years, 7 months ago
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?
<SkilletAudio> Your framerate proves your lack of manhood
Advertisement
Can you define "does not work" in a meaningful way? What error does it return?
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Did you try running with administrative privileges?
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.
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.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
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.
<SkilletAudio> Your framerate proves your lack of manhood
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.
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."

- Jason Astle-Adams

Oops my bad. Still I would never recommend intentionally using forward-slashes.
Glad you solved the issue.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

This topic is closed to new replies.

Advertisement