Copy link to clipboard
Copied
<cfif not directoryExists(arguments.dirPath)>
<cfset directoryCreate(arguments.dirPath)>
</cfif>
Even after checking that the directory doesn't exist, directoryCreate() fails with:
Message: The specified directory {directoryPath} could not be created.
Detail: The most likely cause of this error is that {directoryPath} already exists on your file system.
Ultimately, I want to delete it to quickly clear all files, then recreate it.
I can instead loop through the directory to delete the files, but removing the directory altogether does the job when it's not being weird about whether or not it exists.
Copy link to clipboard
Copied
What is the value of arguments.dirPath? Is it something like "F:\path\to\directory"? Or is it "/path/to/directory"? The first should work, the second should not.
Alternately, you can use an IP address: "//12.12.12.12/path/to/directory".
V/r,
^ _ ^
Copy link to clipboard
Copied
Using the first - N:\folder1\folder2\etc\.
It seems to work intermittently.
I can nix the <cfif> and throw a try/catch around it with an empty catch block. That ultimately does what I want, but I'm thinking I shouldn't have to resort to that.
Copy link to clipboard
Copied
Yeah, I know it just _feels_ hackish.. but probably the best way to work around it.
V/r,
^ _ ^
Copy link to clipboard
Copied
Myka, ColdFusion may be right. It just might be that, once in a while, the wrong value of directory path is passed as an argument to the function.
You should test with:
<cftry>
<cfif not directoryExists(arguments.dirPath)>
<cfset directoryCreate(arguments.dirPath)>
</cfif>
<cfcatch type="any">
<cfdump var="#arguments#">
</cfcatch>
</cftry>
Copy link to clipboard
Copied
Unfortunately, I was working with the same directory the entire time. And I passed the same variable to the directoryExists() and directoryCreate(). That in itself should be consistent, but it was intermittent.
Copy link to clipboard
Copied
Myka wrote:
Ultimately, I want to delete it to quickly clear all files, then recreate it.
As I said elsewhere in this forum. it is advisable in this situation to use named locks.