uploading and showing in the console success vs failure

Jan 18, 2015 at 11:29 PM
Can anyone provide me sample to code to update a file and then output the console or anywhere for that matter the status of the transaction?

using (var file = File.OpenRead(localFileName))
            {
                Console.WriteLine("\rUploading --> " + remoteFileName);
                sftp.UploadFile(file, remoteFileName);
                // display to console status of Upload file
            }
Jan 29, 2015 at 12:51 PM
try this
            using (var file = File.OpenRead(localFileName))
            {
                               Console.WriteLine("\rUploading --> " + remoteFileName);
                               Console.WriteLine("started at " + DateTime.Now+ "");
                               var asynch = sftp.BeginUploadFile(file1, remoteDirectoryInvoiceFileName);
                               var sftpAsynch = asynch as SftpUploadAsyncResult;

                                while (!sftpAsynch.IsCompleted)
                                {
                                    
                                    Console.Write(String.Format("\rUploaded {0} of {1}.", sftpAsynch.UploadedBytes, file.Length));

                                }
                                sftp.EndUploadFile(asynch);
                                Console.WriteLine("Ended at " + (DateTime.Now ) + "");
                
            }