c# - SharpSsh: Restart file transfer if current file transfer too slow? -


my code downloads file remote server our server.

usually, 1 file takes, @ most, minute complete download. there times download takes on 5 minutes.

is possible restart download if current download takes, say, on 5 minutes?

tamir.sharpssh.sshtransferprotocolbase sshcp; sshcp = new scp(sessionoptions.hostname, sessionoptions.username); sshcp.password = sessionoptions.password; sshcp.connect();  foreach (umtsfilesstruct u in array) {     try     {         sshcp.get(u.remotefilepath, u.localfilepath);     }     catch (exception ex)     {         using (streamwriter w = file.appendtext(logger._logname))         {             string error = string.format("error downloading file [{0}], remote: {1} & local: {2} ",                 ex.message, u.remotefilepath, u.localfilepath);             logger.log(error, w);         }     } } 

you can try use system.diagnostics.stopwatch timer. when timer.elapsed >= timespan.fromminutes(5) close connection , run posted code again. if file downloaded less 1 minute instance must not forget stop timer , reset value 0 prevent downloading again when file downloaded.

p.s. can try system.timers.timer if had problems system.diagnostics.stopwatch


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -