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
canRead | YES |
canWrite | YES |
isHidden | NO |
lastmodified | {ts '2024-06-12 09:57:09'} |
name | GMS_Work |
parent | \\sashq\root\dept |
path | \\sashq\root\dept\GMS_Work |
size | 0 |
type | directory |
directory listing - test 1 - query
Attributes | DateLastModified | Directory | Link | Mode | Name | Size | Type |
directoryLink: //sashq/root/dept/GMS_Work
struct
canRead | YES |
canWrite | YES |
isHidden | NO |
lastmodified | {ts '2024-06-12 09:57:09'} |
name | GMS_Work |
parent | \\sashq\root\dept |
path | \\sashq\root\dept\GMS_Work |
size | 0 |
type | directory |
directory listing - test 2 - query
Attributes | DateLastModified | Directory | Link | Mode | Name | Size | Type |
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.
Copy link to clipboard
Copied
Does using the file protocol help? For example, file:///c:/ for the C drive.
Copy link to clipboard
Copied
No, that didn't work.
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?
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.
Copy link to clipboard
Copied
The tests I had in mind are:
<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">
<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">
Copy link to clipboard
Copied
A few things:
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.
Copy link to clipboard
Copied
Thanks for the update, and glad to have helped.