在Vista C驱动器中写入文件时出错 [英] Error while writing to file in Vista C drive

查看:160
本文介绍了在Vista C驱动器中写入文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我需要写入Vista中C:\ Program Files(X86)中存在的文件.我正在使用C#以编程方式写入该文件,但我无法做到这一点.请提出解决方案.

谢谢,
Jagjot

Hello Friends,

I need to write to a file which exists in C:\Program files (X86) in vista. I am using C# to write to that file programatically, but I am not able to do that. Please suggest a solution.

Thanks,
Jagjot

推荐答案

您根本不应该在Program Files下编写任何内容.该位置下的每个文件夹对普通用户都是只读的.您必须选择一个更合适的位置来写入所需的数据.

如果要在同一台计算机上的应用程序的用户之间共享数据,则必须将其写到System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData)返回的路径下的某个位置.
You shouldn''t be writing anything at all under Program Files. Every folder under that location is ReadOnly to normal Users. You have to pick a more appropriate location to write the data you want.

If you''re looking at sharing data between users of the application on the same machine, then you have to write it to something under the path returned by System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData).


您需要可能会更改用户帐户控件中的某些设置.
You need to probably change some settings in the User Account Control.


您可能必须以管理员身份运行应用程序和/或以编程方式要求FileIOPermission,以便您在此处进行编写.

看看这些:

http://stackoverflow.com/questions/2432329/how-do-i-deploy-applications-in-run-as-administrator-mode [ http://msdn.microsoft.com/en-us/library/system. security.permissions.fileiopermission.aspx [ ^ ]

祝你好运!
You will probably have to run your application as an administrator and/or programmatically demand FileIOPermission that lets you write there.

Have a look at these:

http://stackoverflow.com/questions/2432329/how-do-i-deploy-applications-in-run-as-administrator-mode[^]

http://msdn.microsoft.com/en-us/library/system.security.permissions.fileiopermission.aspx[^]

Good luck!


这篇关于在Vista C驱动器中写入文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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