|
-
Apr 8th, 2004, 04:35 PM
#1
Thread Starter
Lively Member
one directory above app.path (Resolved)
I want to create a file but 1 directory above app.path.
app.path & ???? & "\test1.txt"
in unix it would be \.. to go to the above directory
what does ???? need to be to achieve this
Last edited by vbuser1; Apr 14th, 2004 at 06:14 PM.
-
Apr 8th, 2004, 05:15 PM
#2
Frenzied Member
You could read the current path and strip out everything after the second \ from the right and then use the remaining path as your string.
-
Apr 8th, 2004, 05:41 PM
#3
VB Code:
Dim i As Integer
i = InStrRev(App.Path, "\")
MsgBox Left$(App.Path, i)
Has someone helped you? Then you can Rate their helpful post. 
-
Apr 9th, 2004, 02:01 AM
#4
vbuser1
Or
app.path & "\..\test1.txt"
-
Apr 9th, 2004, 09:02 AM
#5
Frenzied Member
All that does is add \..\test1.txt to the current path, not bring it up a level.
-
Apr 9th, 2004, 09:08 AM
#6
OK, then it is
app.path & "\..\..\test1.txt"
-
Apr 9th, 2004, 09:23 AM
#7
Frenzied Member
All you are doing is adding the string to app.path, it wont use the \.. command like you can at the command prompt, which is really cd.. for Windows.
-
Apr 9th, 2004, 09:27 AM
#8
Fanatic Member
Why dont you get App.Path and then remove the name of the folder the application is in ?!
C#.net, VB, C++, Java, VS 2005/2008
Dont' forget to rate posts that are helpful to you.
-
Apr 9th, 2004, 09:29 AM
#9
BrianS,
You are incorect. I use relative paths all the time to get to files. The OS understands this and it does work.
-
Apr 9th, 2004, 09:53 AM
#10
Member
Randem's method works. And it's
to get the parent directory.
Leecher
-
Apr 9th, 2004, 10:07 AM
#11
Frenzied Member
Then please explain what I'm doing wrong to try his example:
VB Code:
Option Explicit
Dim path As String
Private Sub Form_Load()
MsgBox App.path
path = App.path & "\.."
End Sub
? app.Path
C:\Program Files\Microsoft Visual Studio\VB98
? path
C:\Program Files\Microsoft Visual Studio\VB98\..
-
Apr 9th, 2004, 10:11 AM
#12
Member
The string will read "C:\1\2\3\.."
But if you try to create "Test.txt" in "C:\1\2\3\.." it will actually create "C:\1\2\Test.txt".
Leecher
-
Apr 9th, 2004, 03:58 PM
#13
Originally posted by BrianS
Then please explain what I'm doing wrong to try his example:
VB Code:
Option Explicit
Dim path As String
Private Sub Form_Load()
MsgBox App.path
path = App.path & "\.."
End Sub
? app.Path
C:\Program Files\Microsoft Visual Studio\VB98
? path
C:\Program Files\Microsoft Visual Studio\VB98\..
I have to agree with Brian in this case... I get the same results
Has someone helped you? Then you can Rate their helpful post. 
-
Apr 9th, 2004, 04:06 PM
#14
manavo11
You should... You have to create the file or open it. It is not in human format, the OS understands it thought. Use it like this:
App.Path & "\..\Test.txt"
Last edited by randem; Apr 9th, 2004 at 04:40 PM.
-
Apr 9th, 2004, 04:34 PM
#15
So you're right
I did :
VB Code:
Private Sub Form_Load()
Dim FF As Integer
FF = FreeFile
Open App.Path & "\..\Test.txt" For Output As #FF
Close #FF
End Sub
and it worked
Has someone helped you? Then you can Rate their helpful post. 
-
Apr 14th, 2004, 06:13 PM
#16
Thread Starter
Lively Member
Resolved
app.path & "\..\test1.txt"
does work when creating a file but the path when display to the screen doesn't match. Thank you all.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|