Richard Crawford wrote:
> Is there a way in Cold Fusion to make changes to a text file without
> actually opening that file?
Well, that really depends on what you mean by "open." Regardless though,
you can accomplish what you're looking for...
> Suppose, for example, that I have a file "myfile.html" which contains
> the string "***REPLACE_THIS***". How can I have Cold Fusion replace
> that string in the file?
Your code would look something like:
<!--- Read contents of file to a variable --->
<CFFILE ACTION="Read" FILE="C:\Temp\myFile.html" VARIABLE="fileContents">
<!--- Replace place holder text --->
<CFSET fileContents = Replace(fileContents, "***REPLACE THIS***", "Hi
Mom!")>
<!--- Overwrite file with new contents --->
<CFFILE ACTION="Write" FILE="C:\Temp\myFile.html" OUTPUT="#fileContents#">
The above code would replace the place holder text with "Hi Mom."
--
Mosh Teitelbaum
evoch, LLC
Tel: (301) 942-5378
Fax: (301) 933-3651
Email: [EMAIL PROTECTED]
WWW: http://www.evoch.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:138144
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics.
http://www.fusionauthority.com/signup.cfm