简体   繁体   中英

using Environment.CurrentDirectory as db storage directory

If this example using Environment.CurrentDirectory directory as storage folder like

private static string DbFile
{
    get { return Environment.CurrentDirectory + "\\MyDb.sqlite"; }
}

where exactly should I put dbfile to be accessed from visual studio project, and is it ok to use this Environment.CurrentDirectory directory in production code, if yes where should be stored in production.

This is not a good choice of folder.

If you want a path specific to a user, use Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) .

If you want a path specific to the application, then AppDomain.CurrentDomain.BaseDirectory or Application.StartupPath are worth considering.

Environment.CurrentDirectory is the directory from where your application is started. See msdn for more info.

I wouldn't rely on it for production though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM