App.Path是获得当前目录的,那如何获得上一级目录呢?不会真要解析App.Path字符串吧?

解决方案 »

  1.   

    解析字符串很难吗?
    用 instrrev() 检测 \ 的位置再截取就可以了。
    也就是几行代码。
      

  2.   

    我使用的方法为:
       Dim iLen As Integer
        Dim i As Integer
        iLen = Len(App.path)
        For i = iLen To 1 Step -1
            If Mid(App.path, i, 1) = "\" Then
                Outpath = Left(App.path, i)
                Exit For
            End If
        Next i总感觉很麻烦,VB没有系统函数来操作吗?
      

  3.   

    经过楼上的提醒,改成
        Dim iLen As Integer
        Dim i As Integer
        iLen = Len(App.path)
        i = InStrRev(App.path, "\")
        Outpath = Left(App.path, i)谢谢了。
      

  4.   

    用FSO
      Fol.ParentFolder
      

  5.   

    做成一个public通用函数很容易,在整个工程中使用就象内置函数一样。
    我个人不建议 fso,毕竟为了这么一个小功能而调用一个大对象,所消耗的资源是不合算的。