/// <summary> /// Creates a DocumentImage object using the path of the image provided. /// </summary> /// <exception cref="System.Exception">Thrown when the image does not exist or is not one of the allowed types</exception> /// <param name="filePath">The path of the image for which the DocumentImage will be created</param> public DocumentImage(string filePath) { if (File.Exists(filePath)) { //try to get the extention string ext = Path.GetExtension(filePath).TrimStart('.').ToUpper(); switch (ext) { case "TIFF": case "TIF": type = IMAGE_FILE_TYPE.TIFF; break; case "PDF": type = IMAGE_FILE_TYPE.PDF; break; default: throw new Exception("Image Type Not Allowed"); } this.data = File.ReadAllBytes(filePath); } else { throw new Exception("File does not exist"); } }
/// <summary> /// Creates a DocumentImage object using the IMAGE_FILE_TYPE and binary data provided /// </summary> /// <param name="type">The type of Image provided</param> /// <param name="data">The binary data of the Image</param> public DocumentImage(IMAGE_FILE_TYPE type, byte[] data) { this.type = type; this.data = data; }
/// <summary> /// Adds a DocumentImage to this Filing /// </summary> /// <param name="type">The DocumentImage type of the image being added</param> /// <param name="data">The binary data of the image being added</param> public void AddDocumentImage(IMAGE_FILE_TYPE type, byte[] data) { DocumentImage file = new DocumentImage(type, data); this.documents.Add(file); }