Finding directory of VB project dynamically

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2007
Posts: 42
Reputation: Chris147 is an unknown quantity at this point 
Solved Threads: 2
Chris147 Chris147 is offline Offline
Light Poster

Re: Finding directory of VB project dynamically

 
0
  #11
Dec 6th, 2007
Oops! That should be string length = (string length -1)

I was right about the FSO Property though - it's GetParentFolderName - so no need to mess with strings at all!

Chris.
Q - P = A
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 42
Reputation: Chris147 is an unknown quantity at this point 
Solved Threads: 2
Chris147 Chris147 is offline Offline
Light Poster

Re: Finding directory of VB project dynamically

 
0
  #12
Dec 6th, 2007
OK, so I've just spotted another mistake. Where I have Set fldrs = fso.GetFolder("C:\Program Files") it should be Set fldrs = fso.GetFolder(YOUR PARENT FOLDER PATH HERE)

It's been a long day..!
Q - P = A
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Finding directory of VB project dynamically

 
0
  #13
Dec 6th, 2007
Originally Posted by Mr.Wobbles View Post
hkdani - the only potential problem I can see with that is my database is in a different folder than what app.path return, the folders that each are in are in the same location, also I can't really go up a directory and specify the folder name because every time I install them then the folder names change - don't know why.
You are installing them. You are installing what? You are installing the database files after installing the program? You are installing pictures? Need more information. Are you talking about installing the program?

The installer should install the Program in a default location: usually the <Program Files > folder. You need to follow some good practices on your locations: (1) Data that will be used by All Users, should go in the All Users directory, and (2) Data that will be used for the personal user should go in that User's Directory.

Currently I am saving it to a directory that I know where it is (C:/Program Files/PortGen2.0)
That's not a good practice, hard coding locations. You should use the GetEnvironmentVariables with the Environment Class in Visual Basic to find where the Program Files folder is, AllUsers, CurrentUser, etc.

Which allows me to save it, but not restore it because I don't know where to load the file if something were to happen to the old one.
You simply need to save two locations: (1) Your Backup Location, and (2) Your Active Location--or the location you use while running the program. As I wrote before, you should save these values in the registry or in an INI File. O'Reilly prefers saving that type of info in the older type INI file. But you'll need to use the GetPrivateProfileInt from the SDK to use this function. It's easier to use the registry, but O'Reilly says it's probably better to use the INI file

But once you have those two locations saved, you have to program the code based on those values to restore your database. But the first time the program runs, you should have code running in the initialization phase that will save the Active Location, and then you need some kind of menu that spits out a form where you can save the restore location and probably use the same form for restoring your data.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Finding directory of VB project dynamically

 
0
  #14
Dec 6th, 2007
Originally Posted by Mr.Wobbles View Post
hkdani - the only potential problem I can see with that is my database is in a different folder than what app.path return, the folders that each are in are in the same location, also I can't really go up a directory and specify the folder name because every time I install them then the folder names change - don't know why.
You are installing them. You are installing what? You are installing the database files after installing the program? You are installing pictures? Need more information. Are you talking about installing the program?

The installer should install the Program in a default location: usually the <Program Files > folder. You need to follow some good practices on your locations: (1) Data that will be used by All Users, should go in the All Users directory, and (2) Data that will be used for the personal user should go in that User's Directory.

Currently I am saving it to a directory that I know where it is (C:/Program Files/PortGen2.0)
That's not a good practice, hard coding locations. You should use the GetEnvironmentVariables with the Environment Class in Visual Basic to find where the Program Files folder is, AllUsers, CurrentUser, etc.

Which allows me to save it, but not restore it because I don't know where to load the file if something were to happen to the old one.
You simply need to save two locations: (1) Your Backup Location, and (2) Your Active Location--or the location you use while running the program. As I wrote before, you should save these values in the registry or in an INI File. O'Reilly prefers saving that type of info in the older type INI file. But you'll need to use the GetPrivateProfileInt from the SDK to use this function. It's easier to use the registry, but O'Reilly says it's probably better to use the INI file

But once you have those two locations saved, you have to program the code based on those values to restore your database. But the first time the program runs, you should have code running in the initialization phase that will save the Active Location, and then you need some kind of menu that spits out a form where you can save the restore location and probably use the same form for restoring your data.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC