Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Visual Basic for Applications

Post new topic   Reply to topic
Accessing "1-level-up" directory
View previous topic :: View next topic  
Author Message
shivdasn
Regular


Joined: 19 Jun 2005
Posts: 58
Location: India

PostPosted: Jul 22nd, 2005 11:22 AM    Post subject: Accessing "1-level-up" directory Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
DoobieKeebler
Moderator


Joined: 17 Jun 2005
Posts: 254
Location: 181°15'2.003"W, 93°5'16.956"N

PostPosted: Jul 22nd, 2005 02:43 PM    Post subject: Reply with quote

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
View user's profile Send private message
shivdasn
Regular


Joined: 19 Jun 2005
Posts: 58
Location: India

PostPosted: Jul 23rd, 2005 06:31 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Visual Basic for Applications All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic