File Editing

Ryan Chong
Ryan Chong used Ask the Experts™
on
Hi,

I want to edit and save a file in the root directory, how can i do that?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Hi do this ...

<!--- orginal contents of file.cfm --->
<CFSET org = "ryancys">
<CFSET new = "">

<!--- ======================================================================== --->

<cfif fileexists('#root_filepath_with_filename#')><!--- C:\cleints\root\file.cfm --->
   
    <CFINCLUDE TEMPLATE="#root_filepath_with_filename#">
   
    <CFFILE Action="WRITE" file="#root_filepath_with_filename#" output="
       
        <CFSET org = ""#org#"">
        <CFSET new = ""Anand"">
    ">
   
</CFIF>

<!--- ======================================================================== --->

<!--- new contents of file.cfm --->
<CFSET org = "ryancys">
<CFSET new = "Anand">

K'Rgds
Anand
Ryan ChongSoftware Team Lead

Author

Commented:
No realise until use it! I got more from the CFFile tag. Thanks man, Anand :)
Ryan ChongSoftware Team Lead

Author

Commented:
By the way, how to return the root folder? using GetTemplatePath() or ?? Sorry, i dont have Coldfusion installed here so i cant test it now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial