SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Getting Security Exception(FileIOPermission) while opening ZIPFile to read from

Last post 06-29-2009 11:06 PM by nileshpatel.gls. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 06-29-2009 11:06 PM

    Getting Security Exception(FileIOPermission) while opening ZIPFile to read from

     Hi I am getting following security exception in a medium trust environment.

    System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

       at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)

       at System.Security.CodeAccessPermission.Demand()

       at 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)

       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)

       at System.IO.File.OpenRead(String path)

       at FolderZipper.ZipUtil.UnZipFiles(String zipPathAndFile, String outputFolder, String password, Boolean deleteZipFile) in \\stor2wc1dfw1\MyWebsite\web\content\App_Code\class files\ZipUtil.cs:line 81 The action that failed was:

    Demand

    The type of the first permission that failed was:

    System.Security.Permissions.FileIOPermission

    The Zone of the assembly that failed was:

    MyComputer

    My Code is as below :

     

     

    public static void UnZipFiles(string zipPathAndFile, string outputFolder, string password, bool

    deleteZipFile)

    try

    {

    LoggerZip.ErrorFormat(

    "Unzipping File {1}"

    , zipPathAndFile);ZipInputStream s = new ZipInputStream(File.OpenRead(zipPathAndFile));

    Exception occures in above line of code

     

    s.Password = password;

     

     

     

    {

     

     

     

     

    if (directoryName != ""

    )Directory

    .CreateDirectory(directoryName);if (fileName != String

    .Empty)if (theEntry.Name.IndexOf(".ini"

    ) < 0)string fullPath = directoryName + "\\"

    + theEntry.Name;"\\ ", "\\"

    );string fullDirPath = Path

    .GetDirectoryName(fullPath);if (!Directory

    .Exists(fullDirPath))Directory

    .CreateDirectory(fullDirPath);"Directory Created @ {1}"

    , fullDirPath);FileStream streamWriter = File

    .Create(fullPath);"Empty File Created @ {1}"

    , fullPath);int

    size = 2048;byte[ data = new byte

    [2048];while (true

    )if

    (size > 0)

    else

    {

     

    break

    ;if

    (deleteZipFile)File

    .Delete(zipPathAndFile);catch (ZipException

    oZipEx)"Exception occured in Unzip process"

    , oZipEx);throw

    oZipEx;catch (Exception

    oEx)"Exception occured while unzipping file"

    , oEx);throw

    oEx;

Page 1 of 1 (1 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.