This is English speaking forum.
Overall, you can use WinSCP RemoveFile() method to delete a file.
Here is its documentation: library_session_removefile
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Estimado tengo el siguiente codigo que me permite conectarme a un sftp a traves de un ssis pero no se como eliminar el archivo despues de descargar tendran o conceran alguna forma. // Cree un nuevo objeto de proceso para ejecutar WinSCP Process winscp = new Process(); // Establecer la ruta ejecutable y el directorio de descarga winscp.StartInfo.FileName = Dts.Variables["$Package::pWinSCPLocation"].Value.ToString(); winscp.StartInfo.WorkingDirectory = Dts.Variables["$Package::pDownloadDir"].Value.ToString(); // Establecer opciones de ejecución estática (no es necesario cambiarlas) winscp.StartInfo.UseShellExecute = false; winscp.StartInfo.RedirectStandardInput = true; winscp.StartInfo.RedirectStandardOutput = true; winscp.StartInfo.CreateNoWindow = true; // Establecer opciones de sesión string sessionOptionString = "option batch abort" + System.Environment.NewLine + "option confirm off"; // Construya la cadena de conexión (<usuario>: <contraseña> @ <nombre de host>) string connectString = @"open " + Dts.Variables["$Package::pServerUserName"].Value.ToString() + ":" + Dts.Variables["$Package::pServerUserPassword"].GetSensitiveValue().ToString() + "@" + Dts.Variables["$Package::pServerName"].Value.ToString(); // El suministro de la clave de host agrega un nivel adicional de seguridad y evita que se le solicite que confíe en el servidor. string hostKeyString = Dts.Variables["$Package::pServerHostKey"].Value.ToString(); // If hostkey was specified, include it if (hostKeyString != null && hostKeyString.Length > 0) connectString += " -hostkey=\"" + hostKeyString + "\""; // Construye la cadena de comando get string getString = "get " + Dts.Variables["$Package::pFilename"].Value.ToString(); // Cree variables de salida para capturar información de ejecución string outStr = "", errStr = ""; int returnVal = 1; // Este bloque try / catch capturará fallas catastróficas (como especificar la ruta incorrecta a winscp). try { winscp.Start(); winscp.StandardInput.WriteLine(sessionOptionString); winscp.StandardInput.WriteLine(connectString); winscp.StandardInput.WriteLine(getString); winscp.StandardInput.Close(); // Establezca outStr en el valor de salida, ofuscando la contraseña outStr = winscp.StandardOutput.ReadToEnd().Replace(":" + Dts.Variables["$Package::pServerUserPassword"].GetSensitiveValue().ToString() + "@", ":*******@"); // Espere a que salga la aplicación winscp.WaitForExit(); returnVal = winscp.ExitCode; } catch (Exception ex) { errStr = "An error occurred when attempting to execute winscp.com: " + ex.Message.Replace("'", "\"").Replace("—", " – "); } // Variable de no hacer nada requerida para FireInformation a continuación bool fireagain = true; // Registro de salida en registro SSIS if (returnVal != 0 || errStr.Length > 0) // Error { if (errStr.Length > 0) Dts.Events.FireError(0, "WinSCP Exception", errStr.Replace("'", "\"").Replace("—", " – "), "", 0); if (outStr.Length > 0) Dts.Events.FireError(0, "WinSCP error", "A WinSCP error has occurred. The full output stack follows: " + outStr.Replace("'", "\"").Replace("—", " – "), "", 0); } else // No error Dts.Events.FireInformation(0, "WinSCP output", outStr, string.Empty, 0, ref fireagain); Dts.TaskResult = (returnVal != 0) ? (int)ScriptResults.Failure : (int)ScriptResults.Success;
This is English speaking forum.
Overall, you can use WinSCP RemoveFile() method to delete a file.
Here is its documentation: library_session_removefile
Hi @Prieto Velis, Erik Abelardo ,
Please use Execute Process Task to delete the file.
Please refer to Using SFTP with SQL Server Integration Services.
Best regards,
Mona
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.