private void SaveToWordFile() { ScreenCapture sc = new ScreenCapture(); // capture entire screen, and save it to a file System.Drawing.Image img1 = sc.CaptureScreen(); // display image in a Picture control named imageDisplay pictureBox1.Image = img1; // capture this window, and save it; //sc.CaptureWindowToFile(this.Handle, Guid.NewGuid()+".gif", ImageFormat.Gif); img1.Save("Screenshot" + ".jpg", ImageFormat.Gif); counter++; string fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\"; if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\")) { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\"); } if (!File.Exists(fileName + DateTime.Now.ToString("dd-MM-yyyy") + ".docx")) { var docCreate = DocX.Create(fileName + DateTime.Now.ToString("dd-MM-yyyy") + ".docx"); docCreate.Save(); } var docload = DocX.Load(fileName + DateTime.Now.ToString("dd-MM-yyyy") + ".docx"); Image img = docload.AddImage("Screenshot.jpg"); Picture p = img.CreatePicture(); p.Width = 690; p.Height = 365; Xceed.Words.NET.Paragraph par = docload.InsertParagraph(Convert.ToString(counter)); par.AppendPicture(p); docload.Save(); }
private void SaveToImage() { try { if (!Directory.Exists(ImageFileDirectory)) { Directory.CreateDirectory(ImageFileDirectory); } ScreenCapture sc = new ScreenCapture(); // capture entire screen, and save it to a file System.Drawing.Image img = sc.CaptureScreen(); // capture this window, and save it; //sc.CaptureWindowToFile(this.Handle, Guid.NewGuid()+".gif", ImageFormat.Gif); img.Save(ImageFileDirectory + "\\" + "Captured-" + DateTime.Now.ToString("MMddyyyyHHmmss") + ".jpg", ImageFormat.Jpeg); } catch (Exception ex) { flag = true; MessageBox.Show(ex.Message); } finally { ThreadStart(); } }
private void SaveToNewFile() { try { string fileName = !string.IsNullOrEmpty(_FileName) ? _FileName + ".docx" : DateTime.Now.ToString("dd-MM-yyyy") + ".docx"; if (!IsFileLocked(WordFileDirectory + fileName)) { sc = new ScreenCapture(); // capture entire screen, and save it to a file System.Drawing.Image img1 = sc.CaptureScreen(); // capture this window, and save it; //sc.CaptureWindowToFile(this.Handle, Guid.NewGuid()+".gif", ImageFormat.Gif); img1.Save("Screenshot" + ".jpg", ImageFormat.Jpeg); if (!Directory.Exists(WordFileDirectory)) { Directory.CreateDirectory(WordFileDirectory); } if (!File.Exists(WordFileDirectory + fileName)) { var docCreate = DocX.Create(WordFileDirectory + fileName); docCreate.Save(); } var docload = DocX.Load(WordFileDirectory + fileName); Image img = docload.AddImage("Screenshot.jpg"); Picture p = img.CreatePicture(); p.Width = 690; p.Height = 365; Paragraph par = docload.InsertParagraph(Convert.ToString(" ")); par.AppendPicture(p); docload.Save(); } else { MessageBox.Show("The action can't be completed because the file is open in System.", "Error", MessageBoxButtons.OK); } } catch (IOException ex) { flag = true; MessageBox.Show("The action can't be completed because the file is open in System.", "Error", MessageBoxButtons.OK); } catch (Exception ex) { flag = true; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } finally { ThreadStart(); } }
private void SaveToExistingFile() { try { sc = new ScreenCapture(); // capture entire screen, and save it to a file System.Drawing.Image img1 = sc.CaptureScreen(); // capture this window, and save it; //sc.CaptureWindowToFile(this.Handle, Guid.NewGuid()+".gif", ImageFormat.Gif); img1.Save("Screenshot" + ".jpg", ImageFormat.Jpeg); if (!File.Exists(ExistingFileName)) { var docCreate = DocX.Create(ExistingFileName); docCreate.Save(); } var docload = DocX.Load(ExistingFileName); Image img = docload.AddImage("Screenshot.jpg"); Picture p = img.CreatePicture(); p.Width = 690; p.Height = 365; Paragraph par = docload.InsertParagraph(Convert.ToString(" ")); par.AppendPicture(p); docload.Save(); } catch (IOException ex) { flag = true; MessageBox.Show("The action can't be completed because the file is open in System.", "Error", MessageBoxButtons.OK); } catch (Exception ex) { flag = true; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } finally { ThreadStart(); } }
public void SaveToImage() { try { string fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\" + "Image" + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + "\\"; if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\" + "Image" + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + "\\")) { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\" + "Image" + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + "\\"); } ScreenCapture sc = new ScreenCapture(); // capture entire screen, and save it to a file System.Drawing.Image img = sc.CaptureScreen(); // display image in a Picture control named imageDisplay pictureBox1.Image = img; // capture this window, and save it; //sc.CaptureWindowToFile(this.Handle, Guid.NewGuid()+".gif", ImageFormat.Gif); img.Save(fileName + "\\" + "Screenshot" + Guid.NewGuid() + ".jpg", ImageFormat.Gif); } catch (Exception ex) { MessageBox.Show(ex.Message); } }