where should I save my database when I deploy my project

Hi,

I have a C# project which has an Access db. Now for testing I have stored it in my C:\temp folder.
But what is the best place to place the db when I deploy my project? My Documents folder? Or Program Files folder?

Thx!
Pit76Asked:
Who is Participating?
 
Paul ThompsonConnect With a Mentor IT ConsultantCommented:
I don't believe there are any hard and fast rules for the location of an Access database.

However, I'm sure this will be debated...

In general:-

Small, Single user, stand alone application.
Put the database in a Sub-folder below the folder where the .exe resides

MultiUser Application on a single network domain.
A network shared folder created specifically for this application.

Web application.
Sub folder below the web root.

Don't put it in "My Documents" or "Documents". Users will almost certainly re-arrange folders and tidy things up as required. This will break your application. If your database is in "My Documents", users will treat it as one of their own documents they can open and play with. Again, this will break your application. If you don't want users to break your database, its best to hide it away in a folder below the .exe.

If you keep the database with the .exe or in a folder below the .exe, ther will be no confusion that this database belongs to this application.


In larger applications and more formal deployments you would keep the database in:

%AppData%\ApplicationName\

%AppData% is an environment variable that resolves to:-

In XP and 2000...
C:\Documents and Settings\<username>\Application Data\

In Vista and Windows 7...
C:\Users\<username>\AppData\Roaming\

Just type %appdata% in your windows explorer to go there and see how other applications have stored data.

Don't hard code the path, you dont know if it's being deployed to XP, Vista or whatever. Always deploy using the %AppData% environment variable in the deployment path.

Hope this helps

DJ


0
 
kyleroiCommented:
if you only expect one user to use the program than put it in the users folder

http://www.java2s.com/Tutorial/CSharp/0280__Development/Enumerateallspecialfoldersanddisplaythem.htm

otherwise i guess you could put it in program files... this all depends on security.. if you have active directory users may not be able to save to the c:
0
 
Pit76Author Commented:
Thx, great and clear explaination!
I can understand and agree with these recommendations.

Grt!
0
 
Paul ThompsonIT ConsultantCommented:
You may want to take a look at %ProgramData% too.
All users on that machine can access this folder.

%AppData% tends to be user specific.

DJ
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.