daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DirectoryInfo[] dir = new DirectoryInfo[2];
  2. dir[0] = new DirectoryInfo(Server.MapPath("Image/DB/Large/"));
  3. dir[1] = new DirectoryInfo(Server.MapPath("Image/DB/Slide/"));
  4.  
  5. Image signature = Image.FromFile(Server.MapPath("Image/Design/signature.png"));
  6.  
  7. for (int i = 0; i < dir.Length; i++)
  8. {
  9.     FileInfo[] fs = dir[i].GetFiles("*.jpg");
  10.     foreach (FileInfo s in fs)
  11.     {
  12.         FileStream strm = s.OpenRead();
  13.         String name = s.Name;
  14.         System.Drawing.Image img = System.Drawing.Image.FromStream(strm);
  15.  
  16.         Graphics g = Graphics.FromImage(img);
  17.         g.SmoothingMode = SmoothingMode.HighQuality;
  18.         g.DrawImage(signature, new Point(0, 0));
  19.         g.Dispose();
  20.  
  21.         strm.Close();
  22.  
  23.         if (i == 0)
  24.         {
  25.             String v = Server.MapPath("Image/DB/Large/" + name);
  26.             img.Save(v);
  27.         }
  28.  
  29.         else if (i == 1)
  30.         {
  31.             String v = Server.MapPath("Image/DB/Slide/" + name);
  32.             img.Save(v);
  33.         }
  34.     }
  35. }
  36.    
  37. [ArgumentException: .] System.Drawing.Image.FromStream(Stream stream, Boolean
  38.  useEmbeddedColorManagement, Boolean validateImageData) +1065883
  39.  System.Drawing.Image.FromStream(Stream stream) +8 Developer.Page_Load(Object sender,
  40.  EventArgs e) in f:.NET Programming‫FaieqSahwish_V.2.0Developer.aspx.cs:29
  41.  System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t,
  42.  EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
  43.  EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99
  44.  System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean
  45.  includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
  46.    
  47. using System;
  48. using System.Collections.Generic;
  49. using System.Linq;
  50. using System.Text;
  51. using System.Threading.Tasks;
  52. using System.Drawing;
  53. using System.IO;
  54.  
  55. namespace ConsoleApplication2
  56. {
  57.     class Program
  58.     {
  59.         static void Main(string[] args)
  60.         {
  61.             DirectoryInfo dir = new DirectoryInfo(@".");
  62.  
  63.             FileInfo[] fi = dir.GetFiles("*.jpg");
  64.  
  65.             FileStream fs = fi[0].OpenRead();
  66.  
  67.             //FileStream fs = new FileStream("New Bitmap Image.jpg", FileMode.Open);
  68.             System.Drawing.Image.FromStream(fs);
  69.         }
  70.     }
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top