The many ways to list the contents of a directory
Let me start off by saying that this does not just relate to using cfdirectory but really any tag or function that deals with some type of absolute path. I came across this problem at work as we were trying to list the contents of a directory that resides on a remote machine. First let's take a look at the solution if we were trying to do this on our local machine. Here we can either hard code the exact location of the directory or if we know its right below the directory we are working with we can expand the current path.
This is fairly straight forward so far because we are dealing with local machine resources. When we start talking about a remote machine we are getting into account privileges on a domain. I am the first to tell you I am not an expert when it comes to server administration so If I explain something wrong call me out on it. In a default ColdFusion installation the service is run under the local system account and that usually will not have any privileges to outside resources. You either need to grant permissions to that account or you need to create a new account that has the necessary permissions. Once you have that done you can start working with outside resources.
Another thing to remember here is that we are working with absolute paths. In our case we had a virtual directory in IIS pointing to a share drive. Even though this is browsable you can not use "/vdname" to list the contents of a directory. You can however use expand path with the virtual directory name to get the path. In the end that will expand out to the UNC path of the directory. Another option you can use the ip address of the machine. As you can see there are many ways to list the contents of a directory. In my case it was a permissions issue so I would always start will full permissions and work your way backwards.
