| View previous topic :: View next topic |
| Author |
Message |
shivdasn Regular

Joined: 19 Jun 2005 Posts: 58 Location: India
|
Posted: Jul 22nd, 2005 11:22 AM Post subject: Accessing "1-level-up" directory |
|
|
Hey!
I am maing an app which runs at a location, say C:\myapp\dir1. Now i want to make a command button which could access files located in, say C:\myapp\dir2. There could be many such directories like C:\myapp\dir3, C:\myapp\dir4 and so on. i am sure that the files which i need to access WILL be in \mydir. but now if my app runs in C:\myapp\dir1, then i can access all directories and files located in C:\myapp\dir1 by using "app.path". but how do i access a file in the directory C:\myapp\dir2. This is something like pressing the "Go-up-one-level" button in Windows Explorer and then selecting dir2. I have to distribute this application. so i cannot hardcode the path in the project. what can i do? _________________ ..::-- '' D a s ''--::.. |
|
| Back to top |
|
DoobieKeebler Moderator

Joined: 17 Jun 2005 Posts: 254 Location: 181°15'2.003"W, 93°5'16.956"N
|
Posted: Jul 22nd, 2005 02:43 PM Post subject: |
|
|
In DOS (and *nix, if you ever need to go up one level with a website page) "one level up is "..". I'm not totally sure what you're trying to do, but these examples should help.
ThePath = App.Path ' let's say this is c:\myapp\dir1
ThePath = App.Path & "\..\dir2" ' ThePath is now c:\myapp\dir2
ThePath = App.Path & "\..\" ' ThePath is now c:\myapp
You don't have to do this with just App.Path, either. You can directly change an object's path the same way.
File1.Path = "c:\myapp\dir1" ' just for someplace to start
File1.Path = File1.Path & "\..\dir2" ' File1.Path is now c:\myapp\dir2
File1.Path = File1.Path & "\..\" ' File1.Path is now c:\myapp
You can go up as many levels as you want, too. Let's say you're going from c:\myapp\dir1 to c:\yourapp\dir3. Assuming File1.Path is c:\myapp\dir1, to get to c:\yourapp\dir3 you'd say:
File1.Path = File1.Path & "\..\..\yourapp\dir3"
This says, "Go up one level (c:\myapp). Go up one more level (c:\). Now go into c:\yourapp. Now go into c:\yourapp\dir3". |
|
| Back to top |
|
shivdasn Regular

Joined: 19 Jun 2005 Posts: 58 Location: India
|
Posted: Jul 23rd, 2005 06:31 AM Post subject: |
|
|
Hey Thanx a LLLOT man....... I knew about the "cd.." command in DOS, but dint know how to use it in VB. But now i know, thanx 2 u !!
Thanx again.... _________________ ..::-- '' D a s ''--::.. |
|
| Back to top |
|
|