Problem with Setup Project in Visual Studio 2010
I'm trying to create a Setup for my app using the Setup Project wizard in Visual Studio 2010. One of the files I added to the Setup Project is a database (.sdf) file that gets installed in the same folder as the main executable file. The problem is that when I try to run the app a开发者_JAVA百科fter I install it, I get an "Access to the database file is not allowed" error message. If I change the database file's permissions after installed, I can run the program successfully. But that should be done by the installation program. I also tried adding a manifest file to my app, and then rebuild and reinstalled. This way it worked but I had to accept an annoying security message box every time I run the application. So, is there any way to program the installer to copy the file with full permissions?
Yeah, I had this problem too.
I think in most cases you really ought not to run application config files from a common installation path. I'm pretty sure it's considered a poor practice, but that'll only really matter on systems with multiple user accounts.
Anyway, I "solved" my problem by writing my config files for my project in to users "home" directory.
Environment.GetFolderPath(Environment.SpecialFolder.Personal)
That'll return a String with the path to that particular user's "My Documents" folder. So, if you save in there, for example, you'll have write access AND multiple users on the same machine will be able to co-run your application.
I got the above line from here.
精彩评论