首先,我清楚我使用ASP.NET 4.5和DefaultAppPool(集成4.0).我还配置了对DefaultAppPool用户的匿名访问.我已经授予了对DefaultAppPool的所有访问权限.System.Security.Principal.WindowsIdentity.GetCurrent()方法给我相同的用户.但是当下一行运行时,它给了我Access to the path 'XXXX' is denied.例外.然后出于测试目的,我已经授予EveryOne用户所有权利,但仍然得到相同的错误.这是代码行.注意桁架
using (ZipArchive archive = new ZipArchive(zipStream))
{
foreach (ZipArchiveEntry file in archive.Entries)
{
file.ExtractToFile(location,true);
}
}
Run Code Online (Sandbox Code Playgroud)
这是StackTrace,
[UnauthorizedAccessException: Access to the path 'XXX' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +10793558
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1352
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +65
System.IO.Compression.ZipFileExtensions.ExtractToFile(ZipArchiveEntry source, String destinationFileName, Boolean overwrite) +96
XX.XX.XX.ExtractZipFile(Stream zipStream, String location) in XX.cs:44
XX.XX.XX.XX.XX.XX.ExtractZipFile(Stream zipStream, String location) in XXX.cs:17
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
4362 次 |
| 最近记录: |