Access to the path is denied

本文解决ASP.NET程序在不同机器上因文件写权限不足导致的访问拒绝问题,提供两种解决方案:一是修改machine.config文件中的进程模型设置;二是通过Web.Config启用模拟身份。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.提示:Access to the path : C:\pbmis\cfg.xml is denied.

asp.net程序目录放在系统盘,ntfs格式。   

   程序中对cfg.xml有写入操作。   

   运行的时候出现了这个问题。   

   在我自己的机器上没有问题   

   一到别人的机器上就出现这个错误了   

没有写权限   

用文本编辑器打开位于    %systemroot%\microsoft.net\framework\v1.1.4322\config    下的    machine.config    文件,找到    <processmodel>    节,设置    username="system"    。     

2.虚拟空间上经常出现access to the path X:XX is denied,尤其是一些诸如Xml,Lrc为扩展名的文件,其解决方法为:

在Web.Config的<System.Web>里加<identity impersonate="true"/>节点即可.

解释:对你要操作的文件目录增加用户,也就是ASP.net的用户,一般都是“IUSER_computerName”.

Application: ASD880.exe CoreCLR Version: 9.0.24.52809 .NET Version: 9.0.0 Description: The process was terminated due to an unhandled exception. Exception Info: System.UnauthorizedAccessException: Access to the path is denied. at ASD880.View.SerialPortCommunication.SendDataAsync(Byte[] data) in C:\Users\asd\Desktop\充电头网PD31\ASD880\Page Navigation App\View\Communication.xaml.cs:line 59 at ASD880.View.BatteryMode.executePipeline(JArray jsonArray, Boolean PipeResult, Int32 frequency) in C:\Users\asd\Desktop\充电头网PD31\ASD880\Page Navigation App\View\BatteryMode.xaml.cs:line 1407 at ASD880.View.BatteryMode.ProjectStart_Click(Object sender, RoutedEventArgs e) in C:\Users\asd\Desktop\充电头网PD31\ASD880\Page Navigation App\View\BatteryMode.xaml.cs:line 890 at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at ASD880.App.Main() 分析错误
最新发布
06-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值