I have actually gone through stackoverflow answers for the same question asked before. I understood that this problem is being caused because of restricted permission in Program Files
folder.
I have gone through this answer at https://stackoverflow.com/a/5714111/1182021, and the same solution is being all over the web
If the MDB file is in your application path, then the default permissions would require elevation of rights to be able to write to the files -- I'd recommend moving the data to the ApplicationData shared folder, where end users will have write permissions by default
My query is in continuation to the above solution only:
I have globally changed my database path to Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
and from there I wish to access my database as it will be a public access folder (I surfed and came to this conclusion)
- How to define this while deploying the application? Means when I am deploying my
Setup and Deployment project
it automatically puts my database files in myC:\Program Files\MyApplication\
and so my application is not able to access the database at theApplicationData
folder. - Secondly, is this the only way? Can't I get my database into my installed directory and give full permission to my application to access my DB?
I have definitely read TomTom
answer at https://stackoverflow.com/a/14611895/1182021 but still if any trick that can do and which is feasible and advisable.