Exemplo n.º 1
0
 void DirSearch(string sDir, FtpLib.FtpConnection ftp, string currentDirectory, bool createWorldFolder = false, bool first = false)
 {
     try
     {
         ftp.SetCurrentDirectory(currentDirectory);
         if (createWorldFolder)
         {
             if (!ftp.DirectoryExists(owlWorldName))
             {
                 ftp.CreateDirectory(owlWorldName);
             }
             ftp.SetCurrentDirectory(owlWorldName);
             currentDirectory = owlWorldName;
         }
         foreach (string f in Directory.GetFiles(sDir))
         {
             Uri    uri = new Uri(f);
             string str = f.ToLower();
             if (first)
             {
                 if (str.Contains("channel1.txt") || str.Contains("channel2.txt") || str.Contains("channel3.txt") || str.Contains("channel4.txt") || str.Contains("channel5.txt"))
                 {
                     ftp.PutFile(f, System.IO.Path.GetFileName(uri.LocalPath));
                 }
                 else
                 {
                     continue;
                 }
             }
             else
             {
                 if (!str.Contains("channel1.txt") && !str.Contains("channel2.txt") && !str.Contains("channel3.txt") && !str.Contains("channel4.txt") && !str.Contains("channel5.txt"))
                 {
                     ftp.PutFile(f, System.IO.Path.GetFileName(uri.LocalPath));
                 }
             }
         }
         foreach (string d in Directory.GetDirectories(sDir))
         {
             ftp.SetCurrentDirectory(currentDirectory);
             string dirname = new DirectoryInfo(d).Name;
             if (!ftp.DirectoryExists(dirname))
             {
                 ftp.CreateDirectory(dirname);
             }
             string newCurrentDir = currentDirectory + "/" + dirname;
             DirSearch(d, ftp, newCurrentDir);
         }
     }
     catch (System.Exception e)
     {
     }
 }
Exemplo n.º 2
0
 private bool ExisteDirectorio(ref dynamic datos)
 {
     intentos = _data.FTPIntentos;
     datos.FTP.FTPExisteDirectorio = false;
     while (intentos > 0)
     {
         try
         {
             datos.FTP.FTPExisteDirectorio = clienteFTP.DirectoryExists(datos.FTP.FTPPathDirectorio);
             return(true);
         }
         catch
         {
             intentos = intentos - 1;
         }
     }
     if (intentos == 0)
     {
         throw new SpinException("SpinFTP::No se ha conseguido subir el archivo");
     }
     return(false);
 }