Im пытается сделать действительно простое приложение, чтобы сохранить текущий экран в FTP-каталоге.Сохранить изображение (экран печати) на FTP-ошибке?
Это с таймером, установленным на 5-10 секунд (оно должно быть достаточно для этого ...):
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Interval = int.Parse(textBox4.Text)*1000;
Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(printscreen as Image);
int posx = int.Parse(textBox1.Text);
int posy = int.Parse(textBox2.Text);
graphics.CopyFromScreen(posx, posy, 0, 0, printscreen.Size);
printscreen.Save(@"C:\Teszt\printscreen.jpg", ImageFormat.Jpeg);
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://neo-inv.com/" + "/public_html/filename.jpg");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("xx", "xxxx");
request.UseBinary = true;
printscreen.Save(request.GetRequestStream(), ImageFormat.Png);
}
Я получаю ошибку:
WebException was unhandled Exception:Caught:The operation has timed out. Excepton:Thrown:The operation has timed out.
Первый цикл таймера ОК, второе или третье - это исключение. Большое спасибо за Вашу помощь!
Вы не закрыли запрос, запросите request.close() – Fals
Это не работает. cant компилировать, нет метода request.close. – user3248728