I have a program which has a SQL CE Database file which is the core database that the program relies on which I am storing in CommonAppDataPath. However I noticed that CommonAppDataPath returns this format: "C:\\ProgramData\\Company Name\\Program Name\\22.214.171.124"
The database file will stay consistent regardless of the version of the program so I would like to store the file in "C:\\ProgramData\\Company Name\\Program Name\\".
Currently, I am using the below code to remove the last 8 characters of the string which are "\\126.96.36.199" and it appears to be working.
string commonAppDataPath = Application.CommonAppDataPath.ToString();
for (int i = 0; i < 8; i++)
commonAppDataPath = commonAppDataPath.Remove(commonAppDataPath.Length - 1);
However, I am wondering if there is an "official" way to do this as I am concerned that this method may break since CommonAppDataPath can be unique on every machine.
Am I doing this the best way possible or is there a better method that I can use?
Edit: I also seem to get the following message when the SQL CE file is in the version folder. The program works perfectly fine if I concanate it myself and write to the folder above the version directory, as above. "Access to the database file is not allowed. [ 1884, File Name = C:\\ProgramData\\Company Name\\Program Name\\188.8.131.52\\database.sd