通过vb.net在程序文件中创建文件夹时,访问被拒绝 [英] Access is denied while going to create folder in program file through vb.net

查看:520
本文介绍了通过vb.net在程序文件中创建文件夹时,访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Program文件(将要安装我的应用程序的文件)和
中创建一个名为ErrorLog的文件夹.
但是我无法在程序文件中创建文件夹,访问权限被拒绝,并引发错误.

请帮帮我

[edit]已删除紧急情况,已删除了虚假代码块-OriginalGriff [/edit]

I want to create a folder named ErrorLog in Program files (where my application is going to be installed) and

But I am not able to create folder in Program file, Access is denied error fires.

Please help me

[edit]Urgency removed, spurious code blocks removed - OriginalGriff[/edit]

推荐答案

这是一个权限问题:您没有权限来访问Prorgam文件下的文件夹-并且有充分的理由.

而是将您的日志文件放在应用程序数据"文件夹中. (也有Windows/System32/Logfiles文件夹,但我不确定该权限需要什么权限...)
It is a permissions problem: you do not nhave permission to access folders under Prorgam Files - and for good reason.

Instead, put your log files in the Application Data folder. (there is also the Windows/System32/Logfiles folder, but I am not sure what permissions you will need for that one...)


Windows Vista(及更高版本)将不允许您在没有管理员权限的情况下将文件写入Program Files文件夹.习惯这个主意,并改变您的要求.

保存数据文件的适当位置在相应的特殊文件夹中:

MSDN上的 System.Environment.SpecialFolder [
Windows Vista (and later) will not allow you to write files to the Program Files folder without admin permissions. Get used to the idea, and change your requirements.

The proper place to save data files is in the appropriate special folder:

System.Environment.SpecialFolder on MSDN[^]

I recommend that you use LocalApplicationData to save the log file.


这篇关于通过vb.net在程序文件中创建文件夹时,访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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