this works fine for me
<CFOUTPUT>
#GETDIRECTORYFROMPATH(CGI.
</CFOUTPUT>
giving me :
D:\My Doc\Reference\My-ColdFusio
K'Rgds
Anand
Main Topics
Browse All TopicsI am using GETDIRECTORYFROMPATH(#CGI.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
What version of CF are you using? I'm using CFMX and all the comments below are relevant to results achieved with CFMX and may differ from results achieved with other versions of CF.
1. If you put what you have written directly inside a <cfoutput></cfoutput> tag pair so that you have <cfoutput>GETDIRECTORYFROM
GETDIRECTORYFROMPATH(C:\In
That leads me to wonder if you're instead assigning that code to a variable. Are you, if so, please provide the complete line of code.
2. If you move your #s to the outside and put them in a <cfoutput></cfoutput> tag pair so that you have <cfoutput>#GETDIRECTORYFRO
C:\Inetpub\wwwroot\test\
3. Note that the correct output includes backslashes and no slashes. You said your output includes slashes. That's a red flag right there. I can't say how it is related to the issue of you getting one lone backslash at the end, but I bet there is some relation.
4. Note that the correct output has a capital C. If you're on a machine with a drive that is actually named C and not c, then that's what the output should be.
5. How about using CGI.PATH_TRANSLATED instead of CF_TEMPLATE_PATH? Try <cfoutput>#GETDIRECTORYFRO
c:\inetpub\wwwroot\test\
5. Note that the correct output has a lowercase c. I'm not sure why it is different from the output of <cfoutput>#GETDIRECTORYFRO
Josh
I had <CFSET Path=GETDIRECTORYFROMPATH(
I ended up doing a removechars function on path and using that variable called path1. I am am still curious as to why that happens however.
An article here http://www.systemanage.com
Sure that solution will work on a UNIX box--but guess what it does on a Windows box? If you're sure you'll *never* port or reuse your code on a Windows box then you're in good shape; otherwise, you should *not* use the code weeezl gave you. This code, on the other hand, should never cause any harm:
#replace(GETDIRECTORYFROMP
Josh
No, that won't give you an extra slash. All it will do is replace the first instace of the string "/\" with the string "/" (and note that if you wanted to check for all instances of the string "/\" you'd use #replace(GETDIRECTORYFROMP
You're right--you won't have this problem on a Windows system because it won't add the trailing backslash. But if you port weeezl's code (#replace(GETDIRECTORYFROM
Josh
dmatthews--please read and respond!
Anand--
I'm not sure what it is that you're saying may behave differently in different situations. If you're talking about the value in GETDIRECTORYFROMPATH(CGI.C
Okay, dmatthews--I hope you're still with me here. I'd like you to test the following code and give me your results, please. I do not have UNIX box on which to test or I would test this myself. Thanks! Here's the code:
<cfoutput>#CGI.CF_TEMPLATE
<cfoutput>#GetDirectoryFro
<cfoutput>#Replace(GetDire
<cfoutput>#GetDirectoryFro
Please copy and paste the results into a post in this thread. Please also tell me what version of CF you're running.
Do the results you get look something like this:
C:/Inetpub/wwwroot/test/zt
C:/Inetpub/wwwroot/test/\
C:\Inetpub\wwwroot\test\\
C:\Inetpub\wwwroot\test\
If your results look like that then here's what I think is going on: ColdFusion bug, baby! The last two lines of the output *should* look exactly alike; if they don't, ColdFusion must have a bug. The reason they should look exactly alike is that they're doing the same operations on the variable--they're just doing the operations in a different order. But these particular operations should be transitive and the order shouldn't matter. If the order does matter, that to me is a bug with CF.
If the results you get look like what I wrote above, here's my explanation: when CF does GetDirectoryFromPath on a variable, it removes the trailing backslash along the way but it replaces it before it finishes. In Windows, this works fine. But in UNIX, where there are no backslashes, it does not work. Instead, for some reason the trailing slash is not removed and the appended backslash is just wrong! That could be a little off; the truth could instead be even more simple--when GetDirectoryFromPath has completed its operations it does one last thing: it looks for a trailing backslash and if it isn't there it appends it. But regardless, if either of those theories is correct the output shown above is what you should get on UNIX.
Business Accounts
Answer for Membership
by: anandkpPosted on 2003-03-27 at 20:28:15ID: 8222664
weird,
can i have a look at ur code - i guess shld be some typo .. i dont know - will need to take a look
let me know
K'Rgds
Anand