Solved

CFFILE not creating new file

Posted on 2006-11-19
3
193 Views
Last Modified: 2013-12-24
Hi all,

I have a function that creates a new file for logging: Here is a snippet of the code:

//logpath contains the DIRECT link to the folder in which the file to be saved
<cffile action="append" file="#logPath#" output="#content#" addnewline="yes">

Now, this code was working and the after some more testing (i deleted the file to ensure coldfusion would create the new file again) AND then this an error occured saying the file cannot be found. But isnt it supposed to create it?

Your help is greatly appreciated,




0
Comment
Question by:sydron
  • 2
3 Comments
 
LVL 20

Expert Comment

by:trailblazzyr55
Comment Utility
you have the action attribute set to "append" so it will look for the file, if it's not found it'll toss an error, you'd have to change the action attib to "write" for it to create a new file
0
 
LVL 20

Accepted Solution

by:
trailblazzyr55 earned 500 total points
Comment Utility
you could do something like this...

<cfif fileExists(logPath)>
      <cffile action="append" file="#logPath#" output="#content#" addnewline="yes">
<cfelse>
      <cffile action="write" file="#logPath#" output="#content#">
</cfif>
0
 

Author Comment

by:sydron
Comment Utility
Hi trailblazzyr55,

The CFFILE action="append" will create a file, if the file doest not already exist.

The actual problem with my code was that the value of the direct link was actually not valid, eg i had c:/websites file/wwwroot/etc.. rather than c:/websites/wwwroot/etc.

I have fixed the issue now.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now