Subida de proyecto
This commit is contained in:
833
ftp.cs
Normal file
833
ftp.cs
Normal file
@@ -0,0 +1,833 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FluentFTP;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
using Microsoft.VisualBasic.CompilerServices;
|
||||||
|
|
||||||
|
namespace tsFluentFTP
|
||||||
|
{
|
||||||
|
public class ftp
|
||||||
|
{
|
||||||
|
public static DateTime ObtenerFechaDeModificacion(string Fichero, ServidorFTP ServidorFTP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp, __);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
return ftp.GetModifiedTime(Fichero);
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DescargaFichero(string Fichero, Stream st, ServidorFTP ServidorFTP, Action<FtpProgress> Progreso = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp, __);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
if (!ftp.DownloadStream(st, Fichero, progress: Progreso))
|
||||||
|
throw new Exception("No se ha podido descargar el fichero");
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw new Exception(EX.Message, EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<FtpStatus> DescargaFicheroAsync(string Fichero, Stream st, ServidorFTP ServidorFTP, IProgress<FtpProgress> Progreso = null, FtpVerify Verificacion = FtpVerify.None, CancellationTokenSource ct = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cfg = new FtpConfig();
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
cfg.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
cfg.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
cfg.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
cfg.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
cfg.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
cfg.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Using ftp As AsyncFtpClient = New AsyncFtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto, cfg)
|
||||||
|
var ftp = new AsyncFtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto, cfg);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificadoAsync(ftp,__);
|
||||||
|
FtpStatus t;
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ct is null)
|
||||||
|
{
|
||||||
|
await ftp.Connect();
|
||||||
|
t = (FtpStatus)Conversions.ToInteger(await ftp.DownloadStream(st, Fichero, progress: Progreso));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ftp.Connect(ct.Token);
|
||||||
|
t = (FtpStatus)Conversions.ToInteger(await ftp.DownloadStream(st, Fichero, progress: Progreso, token: ct.Token));
|
||||||
|
}
|
||||||
|
if (t == FtpStatus.Failed)
|
||||||
|
throw new Exception("Error descargando fichero " + Fichero);
|
||||||
|
if (ct is not null)
|
||||||
|
{
|
||||||
|
await ftp.Disconnect(ct.Token);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ftp.Disconnect();
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
// End Using
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw new Exception(EX.Message, EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<FtpStatus> DescargaFicheroAsync(string FicheroLocal, string FicheroRemoto, ServidorFTP ServidorFTP, IProgress<FtpProgress> Progreso = null, FtpVerify Verificacion = FtpVerify.None, CancellationTokenSource ct = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cfg = new FtpConfig();
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
cfg.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
cfg.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
cfg.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
cfg.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
cfg.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
cfg.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Using ftp As AsyncFtpClient = New AsyncFtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto, cfg)
|
||||||
|
var ftp = new AsyncFtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto, cfg);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificadoAsync(ftp,__);
|
||||||
|
FtpStatus t;
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ct is null)
|
||||||
|
{
|
||||||
|
await ftp.Connect();
|
||||||
|
t = await ftp.DownloadFile(FicheroLocal, FicheroRemoto, FtpLocalExists.Overwrite, Verificacion, Progreso);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ftp.Connect(ct.Token);
|
||||||
|
t = await ftp.DownloadFile(FicheroLocal, FicheroRemoto, FtpLocalExists.Overwrite, Verificacion, Progreso, ct.Token);
|
||||||
|
}
|
||||||
|
if (t == FtpStatus.Failed)
|
||||||
|
throw new Exception("Error descargando fichero " + FicheroLocal + " de " + FicheroRemoto + " ");
|
||||||
|
if (ct is not null)
|
||||||
|
{
|
||||||
|
await ftp.Disconnect(ct.Token);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ftp.Disconnect();
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
// End Using
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw new Exception(EX.Message, EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void DescargaFichero(string FicheroLocal, string FicheroRemoto, ServidorFTP ServidorFTP, Action<FtpProgress> Progreso = null, FtpVerify Verificacion = FtpVerify.None)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp, __);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
if (ftp.DownloadFile(FicheroLocal, FicheroRemoto, FtpLocalExists.Overwrite, Verificacion, Progreso) == FtpStatus.Failed)
|
||||||
|
throw new Exception("No se ha podido descargar el fichero " + FicheroRemoto + " en " + FicheroLocal);
|
||||||
|
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw new Exception(EX.Message, EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static async Task<FtpStatus> EnviaFicheroAsync(string FicheroOrigen, string FicheroDestino, ServidorFTP ServidorFTP, IProgress<FtpProgress> Progreso = null, FtpVerify Verificacion = FtpVerify.None, CancellationTokenSource ct = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cfg = new FtpConfig();
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
cfg.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
cfg.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
cfg.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
cfg.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
cfg.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
cfg.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var ftp = new AsyncFtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto, cfg);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificadoAsync(ftp,__);
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
FtpStatus t;
|
||||||
|
if (ct is null)
|
||||||
|
{
|
||||||
|
await ftp.Connect();
|
||||||
|
t = await ftp.UploadFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, false, Verificacion, Progreso);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ftp.Connect(ct.Token);
|
||||||
|
t = await ftp.UploadFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, false, Verificacion, Progreso, ct.Token);
|
||||||
|
}
|
||||||
|
if (ct is not null)
|
||||||
|
{
|
||||||
|
await ftp.Disconnect(ct.Token);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ftp.Disconnect();
|
||||||
|
}
|
||||||
|
if (t == FtpStatus.Failed)
|
||||||
|
throw new Exception("Error enviado fichero " + FicheroOrigen + " a " + FicheroDestino);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
// End Using
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw new Exception(EX.Message, EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public static async Task<FtpStatus> RenombraFicheroAsync(string FicheroOrigen, string FicheroDestino, ServidorFTP ServidorFTP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cfg = new FtpConfig();
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
cfg.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
cfg.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
cfg.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
cfg.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
cfg.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
cfg.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
cfg.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var ftp = new AsyncFtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto, cfg);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificadoAsync(ftp,__);
|
||||||
|
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
await ftp.Connect();
|
||||||
|
if (!ftp.Capabilities.Contains(FtpCapability.MDTM))
|
||||||
|
ftp.Capabilities.Add(FtpCapability.MDTM);
|
||||||
|
|
||||||
|
// MsgBox("renombrando fichero " & FicheroOrigen & " a " & FicheroDestino)
|
||||||
|
bool t = await ftp.MoveFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite);
|
||||||
|
// MsgBox(t)
|
||||||
|
await ftp.Disconnect();
|
||||||
|
if (Conversions.ToInteger(t) == (int)FtpStatus.Failed)
|
||||||
|
throw new Exception("Error renombrando fichero " + FicheroOrigen + " a " + FicheroDestino);
|
||||||
|
return (FtpStatus)Conversions.ToInteger(t);
|
||||||
|
}
|
||||||
|
// End Using
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
Interaction.MsgBox(EX.Message);
|
||||||
|
throw new tsUtilidades.tsExcepcion(EX.Message, EX, "FTP_ERROR.DESCONOCIDO", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void EnviaFichero(string FicheroOrigen, string FicheroDestino, ServidorFTP ServidorFTP, Action<FtpProgress> Progreso = null, FtpVerify Verificacion = FtpVerify.None)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp, __);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
if (!ftp.Capabilities.Contains(FtpCapability.MDTM))
|
||||||
|
ftp.Capabilities.Add(FtpCapability.MDTM);
|
||||||
|
var t = ftp.UploadFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, false, Verificacion, Progreso);
|
||||||
|
if (t == FtpStatus.Failed)
|
||||||
|
throw new Exception("Error enviando fichero " + FicheroOrigen + " a " + FicheroDestino + " ");
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw new Exception(EX.Message, EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EnviaFichero(byte[] FicheroOrigen, string FicheroDestino, ServidorFTP ServidorFTP, Action<FtpProgress> Progreso = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp, __);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
if (!ftp.Capabilities.Contains(FtpCapability.MDTM))
|
||||||
|
ftp.Capabilities.Add(FtpCapability.MDTM);
|
||||||
|
var t = ftp.UploadBytes(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, false, Progreso);
|
||||||
|
if (t == FtpStatus.Failed)
|
||||||
|
throw new Exception("Error enviando fichero ");
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void CreaDirectorio(string Directorio, ServidorFTP ServidorFTP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp, __);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
|
||||||
|
if (!ftp.DirectoryExists(Directorio))
|
||||||
|
{
|
||||||
|
ftp.CreateDirectory(Directorio, true);
|
||||||
|
}
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EliminaFichero(string Fichero, ServidorFTP ServidorFTP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp, __);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
ftp.DeleteFile(Fichero);
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ExisteFichero(string Fichero, ServidorFTP ServidorFTP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp,__);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
if (!ftp.Capabilities.Contains(FtpCapability.MDTM))
|
||||||
|
ftp.Capabilities.Add(FtpCapability.MDTM);
|
||||||
|
return ftp.FileExists(Fichero);
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void RenombraFichero(string FicheroOrigen, string FicheroDestino, ServidorFTP ServidorFTP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
ftp.ValidateCertificate += (_, __) => tsFluentFTP.ftp.ValidarCertificado(ftp,__);
|
||||||
|
switch (ServidorFTP.Seguridad)
|
||||||
|
{
|
||||||
|
case SeguridadFTP.Explicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Explicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SeguridadFTP.Implicita:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.Implicit;
|
||||||
|
ftp.Config.SslProtocols = (System.Security.Authentication.SslProtocols)((int)System.Security.Authentication.SslProtocols.Tls + (int)System.Security.Authentication.SslProtocols.Tls11 + (int)System.Security.Authentication.SslProtocols.Tls12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ftp.Config.EncryptionMode = FtpEncryptionMode.None;
|
||||||
|
ftp.Config.SslProtocols = System.Security.Authentication.SslProtocols.None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftp.Encoding = System.Text.Encoding.UTF8;
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
if (!ftp.Capabilities.Contains(FtpCapability.MDTM))
|
||||||
|
ftp.Capabilities.Add(FtpCapability.MDTM);
|
||||||
|
ftp.MoveFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite);
|
||||||
|
ftp.Disconnect();
|
||||||
|
}
|
||||||
|
catch (tsUtilidades.tsExcepcion EX)
|
||||||
|
{
|
||||||
|
throw EX;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
throw new tsUtilidades.tsExcepcion(EX.Message, EX, "FTP_ERROR.DESCONOCIDO", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static FtpListItem[] ObtieneListaFicheros(string Ruta, ServidorFTP ServidorFTP)
|
||||||
|
{
|
||||||
|
var ftp = new FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto);
|
||||||
|
if (ServidorFTP.Pasivo)
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive;
|
||||||
|
}
|
||||||
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos;
|
||||||
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout;
|
||||||
|
// ftp.Config.ListingCulture = Globalization.CultureInfo.CurrentCulture
|
||||||
|
if (ftp.IsConnected == false)
|
||||||
|
ftp.Connect();
|
||||||
|
FtpListItem[] lf = ftp.GetListing(Ruta);
|
||||||
|
ftp.Disconnect();
|
||||||
|
return lf;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ValidarCertificado(FtpClient control, FtpSslValidationEventArgs e)
|
||||||
|
{
|
||||||
|
e.Accept = true;
|
||||||
|
}
|
||||||
|
private static void ValidarCertificadoAsync(AsyncFtpClient control, FtpSslValidationEventArgs e)
|
||||||
|
{
|
||||||
|
e.Accept = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ServidorFTP
|
||||||
|
{
|
||||||
|
public string Servidor { get; set; }
|
||||||
|
public int Puerto { get; set; }
|
||||||
|
public SeguridadFTP Seguridad { get; set; }
|
||||||
|
public bool Pasivo { get; set; }
|
||||||
|
public int Timeout { get; set; }
|
||||||
|
public string Usuario { get; set; }
|
||||||
|
public string Contraseña { get; set; }
|
||||||
|
public int Reintentos { get; set; }
|
||||||
|
public ServidorFTP(string Servidor, int Puerto, string Usuario, string Contraseña, SeguridadFTP Seguridad = SeguridadFTP.Ninguna, bool Pasivo = false, int timeout = 20000, int Reintentos = 3)
|
||||||
|
{
|
||||||
|
this.Servidor = Servidor;
|
||||||
|
this.Puerto = Puerto;
|
||||||
|
this.Seguridad = Seguridad;
|
||||||
|
this.Pasivo = Pasivo;
|
||||||
|
Timeout = timeout;
|
||||||
|
this.Usuario = Usuario;
|
||||||
|
this.Contraseña = Contraseña;
|
||||||
|
this.Reintentos = Reintentos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SeguridadFTP
|
||||||
|
{
|
||||||
|
Ninguna = 0,
|
||||||
|
Implicita = 1,
|
||||||
|
Explicita = 2,
|
||||||
|
ExplicitaConControl = 3,
|
||||||
|
ExplicitaControlOpcional = 4,
|
||||||
|
SoloControl = 5,
|
||||||
|
SoloDatos = 6
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tsFluentFTP.NET.csproj
Normal file
27
tsFluentFTP.NET.csproj
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<RootNamespace>tsFluentFTPNET</RootNamespace>
|
||||||
|
<PackageId>tsFluentFTPNET</PackageId>
|
||||||
|
<PackageTags>net 8.0, libreria</PackageTags>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AssemblyName>tsFluentFTPNET</AssemblyName>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Authors>davrod</Authors>
|
||||||
|
<Company>Tecnosis S.A</Company>
|
||||||
|
<Description>Utilidades FTP seguro.</Description>
|
||||||
|
<PackageReleaseNotes>
|
||||||
|
- Primera versión.
|
||||||
|
- Comprobar porque se han hecho bastantes cambios respecto al anterior.
|
||||||
|
</PackageReleaseNotes>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="FluentFTP" Version="52.1.0" />
|
||||||
|
<PackageReference Include="tsUtilidades" Version="1.0.5" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
25
tsFluentFTP.NET.sln
Normal file
25
tsFluentFTP.NET.sln
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.13.35828.75 d17.13
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tsFluentFTP.NET", "tsFluentFTP.NET.csproj", "{C71E170C-132F-4B0A-B258-CED77E28FCFC}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{C71E170C-132F-4B0A-B258-CED77E28FCFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C71E170C-132F-4B0A-B258-CED77E28FCFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C71E170C-132F-4B0A-B258-CED77E28FCFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C71E170C-132F-4B0A-B258-CED77E28FCFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {F52C8741-810E-4BB8-BA70-71221C2BADD6}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
Reference in New Issue
Block a user