I’m using ftpwebrequest to upload and download a file. So far my code does what is expected. But, I have a little problem, I have to update my database with the upload and download status of the file.
Fore example, if I’m downloading file(test.exe) from FTPSERVER1 to my local box then I do some logic extraction and then upload that file (test.exe) to FTPSERVER2.
If any chance it fails to download or upload, I have to update my table(column: Error Message) and if everything works, I have to update(column:status)
What is the best approach here ?
I’m thinking (may be not the best way to do it), if it goes to catch block then update the exception message to column “error Message” and if not in the finally block, update the column “status”.
Thanks in Advance.
Usually you can get the response from FTP using GetResponse() method. Incase of any exception you need to catch the exception in catch as you already wrote.
Since you have response so easily you can updated your database.