IOException异常:" A所需的特权不保留由客户端"最好的方法来克服? [英] IOException: "A required privilege is not held by the client." best way to overcome?

查看:134
本文介绍了IOException异常:" A所需的特权不保留由客户端"最好的方法来克服?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写使用C#winform应用程序。在尝试创建一个文本文件,我得到了错误所需的特权不保留的客户端。我GOOGLE了,有事情做与用户的权限。简单地说,我不允许在我选择的道路,这是C创建一个文件:/

I'm writing Winform app using C#. While attempting to create a text file, I got the error "A required privilege is not held by the client." which I googled, has something to do with user's privileges. Simply put, I am not allowed to create a file in my chosen path, which is C:/

试过此解决方案:的 http://www.technitips.com/2010/ 06 / A-所需的特权 - 是 - 不持有由这客户端窗口-7 / 的,只有一次得手。什么是克服这种错误的最好方法?我应该改变我的整个窗口的安全设置?或者更改路径的地方,不需要管理员的许可?

Tried this solution: http://www.technitips.com/2010/06/a-required-privilege-is-not-held-by-the-client-windows-7/, only worked once. What's the best way to overcome this kind of error? Should I change my entire Window's security setting? Or change the path to somewhere that does not need Admin's permission?

推荐答案

也许发现一起的 GetFolderPath

Environment.GetFolderPath(Environment.SpecialFolder.Personal));

从msdndoc为的 SpecialFolder枚举

From the msdndoc for the SpecialFolder enum

该目录用作文档的公共存储库。这种
成员等效于我的文档

The directory that serves as a common repository for documents. This member is equivalent to MyDocuments.

如果你只需要创建一个临时文件,您可以拨打:

If you only need to create a temporary file you can call:

Path.GetTempFilename();



在磁盘上创建并返回一个唯一命名的,零字节临时文件该文件的完整路径,看到的 MSDN文档

这篇关于IOException异常:" A所需的特权不保留由客户端"最好的方法来克服?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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