在ASP.Net中访问文件时出现UnauthorizedAccess异常 [英] UnauthorizedAccess Exception when accessing file in ASP.Net
本文介绍了在ASP.Net中访问文件时出现UnauthorizedAccess异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我在此程序中有问题.当我运行它时,此异常错误来自catalog.cs
Hi
i have a problem in this program .when i run it this Exception error comes from catalog.cs
"UnauthorizedAccess Exception was unhandeled by user code"<br />
"access to the path C:\Inetpub\Searcharoo4\WebApplication\z_Searcharoo.dat is denied"
我通过Visual Studio.net 2010运行代码
问题
找不到路径C:\Inetpub\Searcharoo4\WebApplication\z_Searcharoo.dat
请帮我,我需要它:((<
I run code by Visual studio.net 2010
problem
path C:\Inetpub\Searcharoo4\WebApplication\z_Searcharoo.dat
not found
please help me i need it :((
推荐答案
为该文件提供ASPNET完全访问权限.或使用模拟访问它.
Provide ASPNET full access to that file. Or use impersonation in order to access it.
有两句话要说:
There are two things to say:
- 是一种很好的编程技术,可以将可能引发异常的每个代码块包装在
try/catch
块中并处理错误情况;这将防止您的应用程序异常终止 - ,您将收到该异常,因为您的应用程序没有访问所需文件/文件夹所需的权限;如果您在Windows Vista或7上运行该应用程序,则需要处理 UAC 并以 administrator 身份运行您的应用程序.另一种方法是将文件移动到当前用户文件夹
- is a good programming tecnique to wrap each block of code that could throw an exception in a
try/catch
block and handle the error condition; this will prevent your application to abnormally terminate - you are getting that exception because your application has not the rights required to access the file/folder that you want; If you are running the application on Windows Vista or 7 you need to deal with the UAC and run your application as administrator. Another way could be to move your file to another folder, inside the current user folder
这篇关于在ASP.Net中访问文件时出现UnauthorizedAccess异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文