Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8184545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:32:30+00:00 2026-06-07T01:32:30+00:00

I am using ColdFusion 8. I am creating some code that will create a

  • 0

I am using ColdFusion 8.

I am creating some code that will create a folder and insert a file. The file will be tweaked later by a human.

I create the directory like this:

<cfdirectory action="create" directory="#LOCAL.PathToCreate#">

Next, I need to create a file with the name of index.cfm. Right now, the content that needs to go into the index.cfm file is within Test-21-index.txt. I create the content like this:

<cfsavecontent variable="LOCAL.MyContent">
    <cfinclude template="Test-21-index.txt">
</cfsavecontent>
<cffile action="write" file="#NewTreatmentPath##LOCAL.NewFile#" output="#LOCAL.MyContent#" nameconflict="overwrite">

The content of Test-21-index.txt has ColdFusion code in it. The problem that I am encountering is that when I include the file Test-21-index.txt, the ColdFusion code is being run.

How do I get the code to be created as a text file that is NOT run during the creation of the file?

UPDATE ~ With so many tools available to implement my solution, I just needed the right combination. Instead of reading the file, using cfsavecontent, and then writing the file, I merely copied the file. Ugh. That was way too easy.

<cffile action="copy" source="#CurrentDirectory#\#LOCAL.FileToInclude#" destination="#NewTreatmentPath#\#LOCAL.NewFile#">
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:32:31+00:00Added an answer on June 7, 2026 at 1:32 am

    Rather than using cfinclude, you can use cffile to read the file and then output its contents in the cfsavecontent tag:

    <cffile action="read" file="test-21-index.txt" variable="fileContent" />
    
    <cfsavecontent variable="LOCAL.MyContent">
       <cfoutput>#filecontent#</cfoutput>
    </cfsavecontent>
    
    <!--- or even <cfset LOCAL.MyContent = fileContent /> --->
    
    <cffile action="write" file="#NewTreatmentPath##LOCAL.NewFile#" output="#LOCAL.MyContent#" nameconflict="overwrite">
    

    Code is untested, but I think it should work. I believe you will need to work out the path to test-21-index.txt a little differently, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a file in a new directory using the relative path.
I'm using coldfusion 9 and I'm trying to grab a file from an ftp
Im trying to generate a color gradient using ColdFusion. My current code below works
I am using ColdFusion 9.0.1. I am creating a contest each Monday at midnight.
I am using ColdFusion 9.1.0. I am working on part of a site that
I am using ColdFusion 9.0.1. Let me start by stating that I may not
I am using ColdFusion 8.0.1. I am writing a little code in the application
I am creating a log in form using ColdFusion, but I cannot figure out
Okay basically I am creating a stored procedure that will return data for our
I am using ColdFusion 9.0.1 I have a new site that is accessible through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.