raoulsson
raoulsson

Reputation: 16365

cfquery.recordcount returns 0 on a cfdirectory, but only on windows

I have a query on a directory in Coldfusion 9. Why does this code run on mac giving the expected result but not on windows?

<cfoutput>
<cfset fileLocation = "d:/tmp"> <!--- On mac set to /tmp --->
<cfdirectory
        action = "list"
        directory = "#fileLocation#"
        name = "files"
        >
Files found #files.recordcount# <br/>
<cfquery name="dir" dbtype="query">
        select  *
        from    files
        where   directory = <cfqueryparam value = "#fileLocation#">
</cfquery>
Query gives #dir.recordcount#
</cfoutput>

Both machines run Coldfusion 10 and the directory exists. The output on the mac is

Files found 5
Query gives 5

and on windows

Files found 5
Query gives 0 

Am I missing the obvious?

Upvotes: 0

Views: 1124

Answers (1)

BKK
BKK

Reputation: 2073

Ah my guess is windows reports the directory name as D:\tmp instead of the other slash: D:/tmp. Which is why your directory = #filelocation# isn't returning any matches. You might be able to make this more platform independent as described in this article.

I could have sworn there was a built-in function for this in CF now, but I can't seem to find it.

Upvotes: 3

Related Questions