Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

c# - Where to store windows program data files?

My program contains a sql lite db file which my program creates after first run and then stores the data inside updon app usage. The database builds up over a period of time. The db file is created in the installation directory of the program

I have to update the app on a regular basis when there are bugs fixed, so basically I publish a new msi installer, the installer removes old installation files except db file and install new program files.

Some user's do not install it to the default location so in their selected location the db file is not present.

I want to know if it's ok to store data files to some program data folder outside the install dir ? so that every new update of my program can access the data from that program data folder.. ?

Is there any program data directory in windows xp, vista and 7 ? and how to access it in C#/

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Have a look Environment.SpecialFolder Enum to decide about the right place for your data.

I would vote for Recent folder though, here are other options:

  • ApplicationData (Current users roaming profile)
  • CommonApplicationData (All users on local machine)
  • LocalApplicationData (Current user on local machine)

Get the folder of your choice with

Environment.GetFolderPath(Environment.SpecialFolder.xxx))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...