How to write files in C:\Windows\System32 with full permissions

邮差的信 提交于 2019-12-11 02:25:27

问题


Iam working on POS software using winforms. Iam trying to programmatically writing XML file (which contain some encrypted information about software serial number) to C:\Windows\System32 directory. But when i write i get an error Access denied.

Can anyone please explain how can i write this file with full permissions in this directory in windows 7 as well as in windows XP???

Any other suggestion or better way to do this will also be welcome.

Thanks in advance.


回答1:


You'll need to be an administrator on the machine to write to the Windows directory. In addition, on Vista and later, your process will need to be "elevated" (otherwise known as Run As Administrator). You can configure this on your application's property sheet, as discussed here, or with a bit more work, do it programmatically.

It's bad practice to write to that directory, though, notwithstanding all the (misguided) software that does that. Save your files somewhere else. %appdata% or %localappdata% (directories specifically meant for application data) are good choices.



来源:https://stackoverflow.com/questions/22432782/how-to-write-files-in-c-windows-system32-with-full-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!