Skip to main content
Participant
June 12, 2024
Answered

Windows, cfdirectory and network path

  • June 12, 2024
  • 2 replies
  • 756 views

I have code that reads a network share to get a list of directories which then I compare to another newtwork share to determine if there are duplicate folders (same name folder in both network shares).  I had the code running  correctly on ColdFusion 2016 (Linux) but we are now on ColdFusion 2023 (Windows Server 2022) so i'm working on updating the code to access the network share on the CF2023 server.

 

I've tried just using the network share location but that doesn't return anything and then I tried mapping a drive in Windows to access this share but I get a directory not found error.  I also tired using the linux network share '/nas/root' but that just throws errors saying it doesn't exist (which is to be expected).

 

The code below is what i'm using to test cfdirectory.   It looks like ColdFusion can read and write to the network shares but when I run the cfdirectory to get a listing of directories nothing is returning.  I've been in the weeds so long trying to resolve this that I can't figure it what is happening/not happening.  What am I missing? Thank you for any help you can give me.

 

TESTING CODE

 

 

<cfset directoryLink = "\\sashq\root\dept\GMS_Work">
<cfset fileInfo = getFileInfo (  directoryLink ) > 
directoryLink: <cfoutput>#directoryLink#</cfoutput>
<cfdump var="#fileInfo#" >
<br><br>
    <cfdirectory directory="#directoryLink#" action="list" name="workingFolders" type="dir" recurse="no" > 
    <cfdump var="#workingFolders#"  label="directory listing - test 1">
<br><br>

<cfset directoryLink = "//sashq/root/dept/GMS_Work">
<cfset fileInfo = getFileInfo (  directoryLink ) > 
directoryLink: <cfoutput>#directoryLink#</cfoutput>
<cfdump var="#fileInfo#" >
<br><br>
    <cfdirectory directory="#directoryLink#" action="list" name="workingFolders" type="dir" recurse="no" > 
    <cfdump var="#workingFolders#"  label="directory listing - test 2">

 

OUTPUT

directoryLink: \\sashq\root\dept\GMS_Work

struct

canReadYES
canWriteYES
isHiddenNO
lastmodified{ts '2024-06-12 09:57:09'}
nameGMS_Work
parent\\sashq\root\dept
path\\sashq\root\dept\GMS_Work
size0
typedirectory



directory listing - test 1 - query

 AttributesDateLastModifiedDirectoryLinkModeNameSizeType



directoryLink: //sashq/root/dept/GMS_Work

struct

canReadYES
canWriteYES
isHiddenNO
lastmodified{ts '2024-06-12 09:57:09'}
nameGMS_Work
parent\\sashq\root\dept
path\\sashq\root\dept\GMS_Work
size0
typedirectory



directory listing - test 2 - query

 AttributesDateLastModifiedDirectoryLinkModeNameSizeType

 

    This topic has been closed for replies.
    Correct answer CF_Jen

    This was a permissions issues with the network share.  I had the team match the permissions to the network share that was working and this resolved my issue.  

     

    Thank you for your assistance,

    Jennifer

    ps, I didn't realize that I had two account, that would explain why I was receiving duplicate emails. 

    2 replies

    Charlie Arehart
    Community Expert
    Community Expert
    June 18, 2024

    A few things:

    • This definitely COULD be a permissions issue. How are you running cf? Did you run the installer, which created a service? If so, that is set to run as "system" by default. You may find you'd need to run cf as another user, which has been given permission to access that network folder. 
    • Indeed, what user did cf run as in the Linux environment where things "worked"? 
    • Along the same lines, defining a windows drive mapping is an act that is local to your own windows login. It will not be available to cf if it's running under another account
    • Using the file:// protocol is unnecessary here. The cf tags and functions relating to files and folders don't need that prefix. 
    • Finally, did you realize you're using two different Adobe accounts within this discussion? 
    /Charlie (troubleshooter, carehart. org)
    CF_JenCorrect answer
    Inspiring
    June 20, 2024

    This was a permissions issues with the network share.  I had the team match the permissions to the network share that was working and this resolved my issue.  

     

    Thank you for your assistance,

    Jennifer

    ps, I didn't realize that I had two account, that would explain why I was receiving duplicate emails. 

    Charlie Arehart
    Community Expert
    Community Expert
    June 20, 2024

    Thanks for the update, and glad to have helped. 

    /Charlie (troubleshooter, carehart. org)
    BKBK
    Community Expert
    Community Expert
    June 17, 2024

    Does using the file protocol help? For example, file:///c:/ for the C drive.

    Inspiring
    June 17, 2024

    No, that didn't work.

    BKBK
    Community Expert
    Community Expert
    June 18, 2024

    Odd problem indeed. Could you share how you applied file:///?

     

    The issue  is unlikely to be lack of cfdirectory's access to the network share.  After all, the variable fileInfo exists and has a value. 

     

    What happens when you do the following tests?

    • Place a test file in the directory. That is, something like \\sashq\root\dept\GMS_Work\testFile.txt.
    • Run the code you've given above, experimenting with recurse="yes" in cfdirectory and by leaving out the type attribute.