tags:

views:

19

answers:

2

Hi,

I made a setup project and added a folder for desktop shortcut. My application includes database file as well. When I installed the application and ran the shortcut from desktop, it gave Desktop's path and said ABC.mdb not found.

How can I make it so that when user accesses the shortcut, it finds the database in the folder where user installed the application instead of finding it on desktop.

Thanks a lot.

Furqan

A: 

You need to specify an absolute path to the database.

SLaks
but how can i know where the user will install the application?
You should store your database in the user's Application Data, regardless of the install path. If you really don't want to, however, you can get the install path from `typeof(MyType).Assembly.Location`.
SLaks
So you mean i add a folder, User's Application Data and add my database to that?
No; I mean that you should always put your database in `Path.Combine(Environment.GetSpecialFolder(Environment.SpecialFolderKind.ApplicationData), "Your App's Name\Database.mdb")`
SLaks
I am sorry, I am quite new to vb.net. I used to use vb6. I am really not able to understand where to use the code you gave above. When I create Setup project, I only have a few folders. Where to put your code........ Thanks
Put that in your application as the path to the database.
SLaks
A: 

Install the .mdb file to the same directory as the .exe, then have your .exe look for the .mdb in it's own directory.

Beth
So you mean I write the code in the Menu Form (Startup form), in the load event?
yes, to find the .mdb file to open it in the code
Beth