Skip to content

Store data files in application data directory

Faiz edited this page Feb 23, 2020 · 1 revision

Currently, all files are stored in some subdirectory of the directory the program executes in. This is bad, because in a real environment we will not have permission to write to this directory. The answer is to use a subdirectory of either Documents or AppData.

From here, we can use:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

and then create/check if exists some DrDocx subdirectory of that which we then store as a global and use as a base file path for everything including the db, templates, and temp files like word doc generation stuff.

Clone this wiki locally