Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Windows, cfdirectory and network path

New Here ,
Jun 12, 2024 Jun 12, 2024

Copy link to clipboard

Copied

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

 

Views

404
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 20, 2024 Jun 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. 

Votes

Translate
Community Expert ,
Jun 17, 2024 Jun 17, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 17, 2024 Jun 17, 2024

Copy link to clipboard

Copied

No, that didn't work.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2024 Jun 17, 2024

Copy link to clipboard

Copied

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. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 18, 2024 Jun 18, 2024

Copy link to clipboard

Copied

BKBK,  Odd indeed!

 

Test 1

I added a test file to a folder in the directory.  I removed recurse attributes and type from the cfdirectory

 

 

<cfset directoryLink = "\\nagennas02\GMS_Work\Jennifer38002358948d\TestFile.cfm">

<cfset fileInfo = getFileInfo (  directoryLink ) >
directoryLink: <cfoutput>#directoryLink#</cfoutput>
<cfdump var="#fileInfo#" label="FileInfo"><br><br>

<cfdirectory directory="#directoryLink#" action="list" name="workingFolders" > 
<cfdump var="#workingFolders#"  label="directory listing - test 1">

 

This throws an error for getFileInfo

File or directory //nagennas02/GMS_Work/Jennifer38002358948d/TestFile.cfm does not exist.

 
The error occurred in C:/ColdFusion2023/cfusion/wwwroot/jelume.cfm: line 30
28 : <cfset directoryLink = "\\nagennas02\GMS_Work\Jennifer38002358948d\TestFile.cfm">
29 : 
30 : <cfset fileInfo = getFileInfo (  directoryLink ) >
31 : directoryLink: <cfoutput>#directoryLink#</cfoutput>
32 : <cfdump var="#fileInfo#" label="FileInfo">

 

Test 2

I added a test file to a folder in the directory using the 'file:///'.  I removed recurse attributes and type from the cfdirectory

 

<cfset directoryLink = "file:///\\nagennas02\GMS_Work\Jennifer38002358948d\TestFile.cfm">

<cfset fileInfo = getFileInfo (  directoryLink ) >
directoryLink: <cfoutput>#directoryLink#</cfoutput>
<cfdump var="#fileInfo#" label="FileInfo">
<br><br>

<cfdirectory directory="#directoryLink#" action="list" name="workingFolders" > 
<cfdump var="#workingFolders#"  label="directory listing - test 1">

 

Same error

File or directory file://///nagennas02/GMS_Work/Jennifer38002358948d/TestFile.cfm does not exist.

 
The error occurred in C:/ColdFusion2023/cfusion/wwwroot/jelume.cfm: line 30
28 : <cfset directoryLink = "file:///\\nagennas02\GMS_Work\Jennifer38002358948d\TestFile.cfm">
29 : 
30 : <cfset fileInfo = getFileInfo (  directoryLink ) >
31 : directoryLink: <cfoutput>#directoryLink#</cfoutput>
32 : <cfdump var="#fileInfo#" label="FileInfo">

 

On my VM server I am noticing that ColdFusion is creating a nagennas02 folder on c:\.  This is why my original testing said that it's existing.  When I rename the folder cfdirectory says it's no longer existing.

 

 

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2024 Jun 18, 2024

Copy link to clipboard

Copied

The tests I had in mind are:

  1.  After you have put a test-file in GMS_Work directory
    <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" recurse="no" > 
        <cfdump var="#workingFolders#"  label="directory listing - test 1">
    ​


  2.  With the test-file still in GMS_Work, switch recurse to Yes
    <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" recurse="yes" > 
        <cfdump var="#workingFolders#"  label="directory listing - test 1">​

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2024 Jun 18, 2024

Copy link to clipboard

Copied

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)

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 20, 2024 Jun 20, 2024

Copy link to clipboard

Copied

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. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 20, 2024 Jun 20, 2024

Copy link to clipboard

Copied

LATEST

Thanks for the update, and glad to have helped. 

/Charlie (troubleshooter, carehart.org)

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources