Getting the full file path of a Coldfusion Component in dot-notation

Posted on Sunday, April 11th, 2010 at 11:38 am

When you are creating an instance of a cfc using the <cfobject> tag or createObject() method you need to specify the path to the desired component via a dot-notation file path.  All-in-all this is little more than a file path where the back-slashes are replaced with periods.  However, these paths are not full local paths like when using an absolute path for an image for example.  So the file path will not begin with ‘/Applications’ (if on a mac) or ‘C:/’ (if on windows).  Instead the path begins in the server root, which for Coldfusion is the ‘wwwroot’ directory.

If you are running a package of cfcs or are creating instances from different parts of your application I would recommend creating a mapping to the package or directory containing the cfc(s).  This will save you some work in the future if, say, the application directory structure changes.  You can get the full dot-notation path by introspecting the cfc you are creating an instance of.  I’ve created a short video showing a few ways of getting this file path pretty quickly.  Watch the video.

Leave a Reply

*
(Won't be published) *