Sunday, April 29, 2012 6:55 PM
i have written a small app that:
-Periodically captures a portion of a screen to jpeg file
-Uploads this file to ftp server
At first i used
and it worked like a charm. Then i wanted to move to FtpWebRequest async. The reason was because i implemented a global keyboard hook and locking the main thread for upload, disabled my keyboard.
I copied the example in MSDN regarding FtpWebRequest. the problem i have is that it seems that the file that is being uploaded is locked even after the stream is closed.
MSDN code used: FtpWebRequest MSDN
The timer calls a function to upload the image. In that function a bitmap is created and finally:
and after that i am calling the sub for async ftp upload based on msdn example. After one or two successful uploads, i get a general GDI+ exception which comes because "the file is being used from another process"..If i save to a new file is ok.
I have tried with long intervals in timer (>minute) and it does the same. The file is small (usually 40-50 kb)
I tested that the stream is closed and tried to press the upload manually 10 secs after and i got the same error.
I can't figure out what is happening...
- Edited by e4rthdog Sunday, April 29, 2012 6:56 PM