Link to home
Start Free TrialLog in
Avatar of Ital
Ital

asked on

vb 6 App.Path

hi

the path of my program is  : c:\test\funny\

i do

i got an other folder

c:\test\Magic\Allo.txt

i need to be able to go get that file

with the App.Path

so basacly, what i need is the command to go back one shot. like a CD..

1- be able to go one folder back
thx
Ital
ASKER CERTIFIED SOLUTION
Avatar of Esopo
Esopo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vinnyd79
vinnyd79

you could use split to get the filename:


Private Sub Command1_Click()
Dim arrFile() As String
arrFile = Split("c:\test\Magic\Allo.txt", "\")
If Left(App.Path, 1) <> "\" Then
    MsgBox App.Path & "\" & arrFile(UBound(arrFile))
Else
    MsgBox App.Path & arrFile(UBound(arrFile))
End If

End Sub
   Dim MyDataFile As String
    MyDataFile = StrReverse(App.Path)
    MyDataFile = StrReverse(Right(MyDataFile, Len(MyDataFile) - InStr(1, MyDataFile, "\"))) & "\Magic\Allo.txt"
'strFolder will contain the path to the folder you want

Dim strFolder As String
Dim x As Integer '
For x = Len(App.Path) To 1 Step -1
  If Mid(App.Path, x, 1) = "\" Then
    strFolder = Mid(App.Path, 1, Len(App.Path) - (x + 1))
  End If
Next x
Avatar of Ital

ASKER

Exactly what i needed
its perfect
thx