private void UploadFile(FTPLib.FTP ftp, string path) { ProgressValue = 0; ftp.OpenUpload(path, Path.GetFileName(path)); long fileSize = new FileInfo(path).Length; long position = 0; long bytes = 0; while ((bytes = ftp.DoUpload()) != 0) { if (IsRunning == false) break; position += bytes; try { //throttle progress updates so UI does not flicker var progress = Convert.ToInt32(100.0 * (Convert.ToDouble(position) / Convert.ToDouble(fileSize))); if (progress > ProgressValue) { ProgressValue = progress; } } catch {} } }
private void UploadFile(FTPLib.FTP ftp, string path) { ftp.OpenUpload(path, Path.GetFileName(path)); long fileSize = new FileInfo(path).Length; long position = 0; long bytes = 0; while ((bytes = ftp.DoUpload()) != 0) { if (IsRunning == false) break; position += bytes; try { ProgressValue = Convert.ToInt32(100.0 * (Convert.ToDouble(position) / Convert.ToDouble(fileSize))); } catch { } } }