Forum Discussion

asmatullah's avatar
asmatullah
Contributor
12 years ago
Solved

How to go one level up in folder path .

Hi ,

I am using ProjectSuite.Path to get the path and want to move one level back .

How can I achieve this .





  • Hi,



    I would do it this way (untested VBScript):



    strPath =  ProjectSuite.Path

    strPath = aqFileSystem.ExcludeTrailingBackSlash(strPath)

    strPath = aqFileSystem.GetFileFolder(strPath)



    The last line will return the parent path because after the trailing backslash was removed from the path, aqFileSystem.GetFileFolder() treats everything after the last backslash as a file name and trims it (and in your case this will be the name of the current folder).

    If you need to navigate two levels up, just duplicate two last lines:

    strPath =  ProjectSuite.Path

    strPath = aqFileSystem.ExcludeTrailingBackSlash(strPath)

    strPath = aqFileSystem.GetFileFolder(strPath)

    strPath = aqFileSystem.ExcludeTrailingBackSlash(strPath)

    strPath = aqFileSystem.GetFileFolder(strPath)

3 Replies

  • You can also use this:

    aqFileSystem.GetFolderInfo(Project.Path).ParentFolder.Path
  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    Hi,



    I would do it this way (untested VBScript):



    strPath =  ProjectSuite.Path

    strPath = aqFileSystem.ExcludeTrailingBackSlash(strPath)

    strPath = aqFileSystem.GetFileFolder(strPath)



    The last line will return the parent path because after the trailing backslash was removed from the path, aqFileSystem.GetFileFolder() treats everything after the last backslash as a file name and trims it (and in your case this will be the name of the current folder).

    If you need to navigate two levels up, just duplicate two last lines:

    strPath =  ProjectSuite.Path

    strPath = aqFileSystem.ExcludeTrailingBackSlash(strPath)

    strPath = aqFileSystem.GetFileFolder(strPath)

    strPath = aqFileSystem.ExcludeTrailingBackSlash(strPath)

    strPath = aqFileSystem.GetFileFolder(strPath)