Skip to main content
October 3, 2008
Answered

CFFILE write

  • October 3, 2008
  • 1 reply
  • 915 views
I am trying to create a file using the cffile tag and the following code:
<cfset rootPath = #expandpath("../.")#>
<cfsavecontent variable="controllerScript">
Text to write to file
</cfsavecontent>
<cfif NOT FileExists( ExpandPath( "..\controllers\#url.table#Controller.cfm" ) )>
<cffile action="write" file="#rootPath#\controllers" output="#controllerScript#" nameconflict="error">
\controllers\#url.table#Controller.cfm has been written<br />
<cfelse>
\controllers\#url.table#Controller.cfm all ready existed<br />
</cfif>

When I execute this on my localhost (win xp pro) I get the following error:

An error occurred when performing a file operation write on file C:\Documents and Settings\Jason\My Documents\Sites\devArena\controllers.
The cause of this exception was: java.io.FileNotFoundException: C:\Documents and Settings\Jason\My Documents\Sites\devArena\controllers (Access is denied).

I set the write permissions in IIS and have tried to remove read-only access from all the folders. Directly above this code I do have another piece of code that creates the controllers folder if it does not exist. Is that a problem? Anyone see something that I am missing?

Thanks
    This topic has been closed for replies.
    Correct answer
    Ohh Duhhh! Yes it was more then the file extension. I forgot the entire filename. I left it with just the path to the folder.

    file="#rootPath#\controllers\#tablename#Controller.cfm"

    Thanks

    1 reply

    October 3, 2008
    A file extension maybe?
    Correct answer
    October 3, 2008
    Ohh Duhhh! Yes it was more then the file extension. I forgot the entire filename. I left it with just the path to the folder.

    file="#rootPath#\controllers\#tablename#Controller.cfm"

    Thanks