SQL Agent - Zipfile.ExtractToDirectory not working RRS feed

  • Question

  • Hi.

    I have a SSIS package in which I have a script task.

    I have the below code, which is trying to unzip the file

    string subPath = Dts.Variables["User::ProcessingFolder"].Value.ToString();
    bool exists = System.IO.Directory.Exists(subPath);
     if (!exists)
     string zipFilename = Dts.Variables["User::varProcessingFile"].Value.ToString();
     string targetDirectory = subPath;
     ZipFile.ExtractToDirectory(zipFilename, subPath);
     Dts.TaskResult = (int)ScriptResults.Success;

    The above code works in Visual studio, but when run through the SQL Agent, the unzip is not happening.

    How to fix this ?


    Thursday, October 24, 2019 3:12 PM

All replies

  • Hi Venkatzeus,

    Same like in your previous post.

    You are running SQL Server Agent job under some account. That account needs permissions to read and write 2 locations on the file system: zipFilename and subPath.

    Additionally, your c# code needs some robustness improvements, i.e. error handling and logging.

    Thursday, October 24, 2019 3:24 PM
  • Hi.

    I got the error message as -The script task uses version 15.0 ,script that is not supported in this release of integration service.

    Thursday, October 24, 2019 3:36 PM
  • Hi Venkatzeus,

    It is a different issue altogether.

    What is your SSIS run-time version on the server?

    You need to match it in VS via the TargetServerVersion property.

    Check it out here: VS 2019 for SSIS ?

    Thursday, October 24, 2019 3:48 PM