简体   繁体   English

在Windows 7中从C#WinForms应用程序创建文件

[英]Creating a file in Windows 7 from C# WinForms application

I have a WinForm application which is generating CSV files. 我有一个正在生成CSV文件的WinForm应用程序。 I give the user the option of choosing the path in which to save these CSVs. 我为用户提供了选择保存这些CSV的路径的选项。

The user is using Windows 7 and is logged in as admin. 用户正在使用Windows 7,并且以admin登录。 When he tries to save the CSVs by way of the application, there is an error "permission denied". 当他尝试通过应用程序保存CSV时,出现错误“权限被拒绝”。

The application that is having the issue in particular is the console app. 出现问题的应用程序尤其是控制台应用程序。 We are creating a scheduled task, and the task is specified to start the process as his administrator account. 我们正在创建一个计划任务,并且指定该任务以其管理员帐户身份启动该过程。 However will have issues when the application tries to save a file to the specified folder(to which his username has permission to write to). 但是,当应用程序尝试将文件保存到指定的文件夹(其用户名具有写入权限)时,将出现问题。

Is there a way to allow an administrator of the machine to create folders/files anywhere he has permission to via the application? 有没有办法允许机器管理员在他有权通过应用程序访问的任何地方创建文件夹/文件?

Thank you! 谢谢!

You can either turn the UAC off or require the process to run in an elevated context . 您可以关闭UAC或要求该过程在提升的环境中运行

In general, you should not worry about it unless your application is specially tailored for altering administrative stuff in the system, you should let the user decide to run it in elevated mode. 通常,除非您的应用程序专门为更改系统中的管理内容而定制,否则您不必担心它,您应该让用户决定以提升模式运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM