/// <summary> /// Gets the screenshot image from an image file. This is used when we want to show screenshot images. /// </summary> /// <param name="path">The path of an image file (such as a JPEG or PNG file).</param> /// <returns>The image of the file.</returns> public Image GetImageByPath(string path) { try { Image image = null; if (!string.IsNullOrEmpty(path) && FileSystem.FileExists(path)) { image = FileSystem.GetImage(path); } CaptureError = false; return(image); } catch (Exception ex) { Log.WriteExceptionMessage("ScreenCapture::GetImageByPath", ex); CaptureError = true; return(null); } finally { GC.Collect(); } }
/// <summary> /// Gets the screenshot image from an image file. This is used when we want to show screenshot images. /// </summary> /// <param name="path">The path of an image file (such as a JPEG or PNG file).</param> /// <returns>The image of the file.</returns> public Image GetImageByPath(string path) { try { Image image = null; if (!string.IsNullOrEmpty(path) && _fileSystem.FileExists(path)) { image = _fileSystem.GetImage(path); } CaptureError = false; return(image); } catch (ArgumentException) { // This is likely an image associated with an encrypted screenshot // which was determined as being "normal" but it's actually encrypted // because the screenshot references weren't saved properly. return(null); } catch (Exception ex) { _log.WriteExceptionMessage("ScreenCapture::GetImageByPath", ex); CaptureError = true; return(null); } }