如何在Windows窗体应用程序的C驱动器的ProgramFiles或Windows文件夹内创建文件 [英] how to create a file inside ProgramFiles or Windows folder of C drive in Windows Form application

查看:135
本文介绍了如何在Windows窗体应用程序的C驱动器的ProgramFiles或Windows文件夹内创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 当我试图在Windows窗体应用程序中创建文件时,如何在C驱动器的 Program Files Windows 文件夹中创建文件,它将通过异常


mscorlib.dll中出现"类型为"System.UnauthorizedAccessException"的未处理的异常"

附加信息:拒绝访问路径"C:\ Program Files \ test.xml"."


有什么办法可以在这2个文件夹中创建文件
请建议我该怎么办.

谢谢
Prafulla

解决方案

您需要使用Administrator Privilege来运行您的应用程序.

将以下设置更改为应用程序清单.

 <   requestedexecutionlevel    级别  ="     uiaccess   ="   /  >  


您应该将数据存储在其他位置.写程序文件"文件夹或Windows文件夹未完成".这些是特殊的系统文件夹,您的应用程序请勿触摸它们.


hi How to create a file inside Program Files or Windows folder of C drive when I am trying to create a file in windows form application it will through an exception


"An unhandled exception of type ''System.UnauthorizedAccessException'' occurred in mscorlib.dll

Additional information: Access to the path ''C:\Program Files\test.xml'' is denied."


Is there any way to create file inside this 2 folder
please suggest me how would I do.

Thanks
Prafulla

解决方案

You need to run your application with Administrator Privilege.

Change following settings into your application Manifest.

<requestedexecutionlevel level="requireAdministrator" uiaccess="false" />


You should store your data elsewhere. It is "not done" to write in the Program Files folder, nor the Windows-folder. These are special system-folders, and your app should not touch them.


这篇关于如何在Windows窗体应用程序的C驱动器的ProgramFiles或Windows文件夹内创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆