Skip to main content
Participant
Jul 2, 2020 7:34 PM UTC
Answered

Return root path of a directory

Hello community

I have been researching routes in ColdFusion and I want to know if there is any function that returns the root node of the directory.

Example: C:\mydirectory\myotherdirectory  

output:   C:\         

 

Example: D:\mydirectory\myotherdirectory  

output:   D:\ 

 

 

     

 

 

    This topic is closed to new replies. Start a new post to keep the conversation going.
    BeRadB
    BeRadBCorrect answer
    Inspiring
    Jul 3, 2020 8:46 PM UTC

    #listfirst(expandpath('./'),'/')#

     

    this should return the 'c:' part of the current directory

     

    please note this might not work if you are in a shared environment.

     

    and not too sure this will work on Linux

     

    Iambradb.com Adobe ColdFusion Specialist.

    2 replies

    BKBK
    Community Expert
    Community Expert
    Jul 5, 2020 4:02 PM UTC

    createobject("java", "java.lang.System").getenv("SystemDrive")

    Translate
    BeRadB
    BeRadBCorrect answer
    Inspiring
    Jul 3, 2020 8:46 PM UTC

    #listfirst(expandpath('./'),'/')#

     

    this should return the 'c:' part of the current directory

     

    please note this might not work if you are in a shared environment.

     

    and not too sure this will work on Linux

     

    Translate
    Iambradb.com Adobe ColdFusion Specialist.