Access denied while reading / writing to the FIles program

I have a small program that is installed in a user folder in the program files, but when I tried to read or write the files that are necessary for it to work, the program brings up Access Denied Exeption. How can I enhance the program, of course with the permission of the user.

+1


source to share


4 answers


I assume you are running Vista? On Vista I don't think you are allowed to read / write files in Program Files, you should put your data files in Documents and Settings.



+1


source


To resolve the Access denied exception while reading. Specify file access as read, which will allow access denied exception when read



e.g. fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);

      

+1


source


You can do whatever you need using the ClickOnce API . If you have multiple parts (like more than one EXE), you need to include them in your package.

The only scenario that is not supported (by ClickOnce) as far as I know is proxy authentication.

0


source


ClickOnce supports installing any number of executables, although you may need to manually include them in your manifest definitions.

To be correct and work well under User Access Restrictions (LUA) and User Access Control (UAC), your application should not be written to the program files folder at all, except during installation. If you must, you must include a manifest file that indicates that your application requires elevated privileges to run. (If you're on Vista, you can also set Compatibility Mode.)

0


source







All Articles