Copy link to clipboard
Copied
Hi,
I thought this would be simple.
<cfset
Application.data_directory = ExpandPath("data")>
<cfif
not DirectoryExists(Application.data_directory)>
<cfdirectory action = "create" directory = "#Application.data_directory#" >
</cfif>
<cfset
Application.County_Selections_Path = GetDirectoryFromPath(Application.data_directory) & "CountySelections.json">
county_selections_path=C:\ColdFusion8\wwwroot\CountySelections.json
data_directory=C:\ColdFusion8\wwwroot\data
county_selections_path=C:\ColdFusion8\wwwroot\data\CountySelections.json
data_directory=C:\ColdFusion8\wwwroot\data
I need to be certain I use the correct file seperator ("\") for our systems.
Suggestions?
I think you need to re-read the docs for getDirectoryFromPath(), specifically this bit:
Parameter | Description |
---|---|
path | Absolute path (drive, directory, filename, and extension) |
http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_e-g_36.html#1104945
--
Adam
Copy link to clipboard
Copied
I think you need to re-read the docs for getDirectoryFromPath(), specifically this bit:
Parameter | Description |
---|---|
path | Absolute path (drive, directory, filename, and extension) |
http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_e-g_36.html#1104945
--
Adam
Copy link to clipboard
Copied
Thanks Adam, that's what I needed to get my head level again!
Copy link to clipboard
Copied
Why use backslash at all?
Forward slash is cross-compatible and works in all environments, windows too.
When dealing with paths, I always replace backslashes with forward slashes before I proceed further.
path = replace(path,"\","/","all);
--
-Fernis - http://fernis.net/ - ColdFusion Developer For Hire
Copy link to clipboard
Copied
Personally, I would get the correct file separator like this:
<cfset pathSeparator=createObject("java", "java.lang.System").getProperty("file.separator")/>
Joseph DeVore
http://josephdevore.com
Copy link to clipboard
Copied
Well, personally I think that solution is messy.
I've adoped Sean Corfield's and Ben Nadel's suggestions as best-practice, so that's still what I'd recommand.
http://corfield.org/blog/index.cfm/do/blog.entry/entry/Backslash_is_NOT_a_path_separator
--
-Fernis - http://fernis.net/ - ColdFusion Developer For Hire