2013-02-10 16 views
5

まず、私は、DefaultAppPool(4.0に統合)でASP.NET 4.5を使用していることを確認します。また、DefaultAppPoolユーザーへの匿名アクセスを構成しました。 DefaultAppPoolにすべてのアクセス権を与えました。 System.Security.Principal.WindowsIdentity.GetCurrent()方法は私に同じユーザーを与えます。しかし、次の行が実行されると、私にはAccess to the path 'XXXX' is denied.の例外が与えられます。テスト目的のために、私はEveryOneユーザーにすべての権利を与えましたが、同じエラーが発生しています。ここにコード行があります。ここでExtractToFile throwing Access Denied Error?

 using (ZipArchive archive = new ZipArchive(zipStream)) 
     { 
      foreach (ZipArchiveEntry file in archive.Entries) 
      { 
       file.ExtractToFile(location,true); 
      } 
     } 

は私に間違った例外を与え、この場合の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 

enter image description here

+0

DefaultAppPoolユーザーは、問題のパスへのアクセス権(読み取り/書き込み権限)を持っていますか? – Tim

+0

@Tim、はいフルコントロール。また、私はフルコントロールをEveryoneユーザーに与えました。 – user960567

+0

DefaultAppPoolユーザーは、パス内のすべてのフォルダに対して実行/移動アクセス権を持っていますか? –

答えて

10

.NETフレームワークであるTRUSに注意してください。問題は、私はちょうど場所(ファイル名なしのフォルダの場所)を渡していたということでした。したがって、完全なパスを含めた後、これは機能します。

関連する問題