Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:38:40+00:00 2026-06-11T18:38:40+00:00

i hope anyone to help me in this code that i don’t know where,what

  • 0

i hope anyone to help me in this code that i don’t know where,what and why this problem has tookplace !!

i have this code responsible to get images from directory to make a simple watermark for each one, but there is an exception when the code arrive to read the image as streams..

please look at this code :

DirectoryInfo[] dir = new DirectoryInfo[2];
dir[0] = new DirectoryInfo(Server.MapPath("Image/DB/Large/"));
dir[1] = new DirectoryInfo(Server.MapPath("Image/DB/Slide/"));

Image signature = Image.FromFile(Server.MapPath("Image/Design/signature.png"));

for (int i = 0; i < dir.Length; i++)
{
    FileInfo[] fs = dir[i].GetFiles("*.jpg");
    foreach (FileInfo s in fs)
    {
        FileStream strm = s.OpenRead();
        String name = s.Name;
        System.Drawing.Image img = System.Drawing.Image.FromStream(strm);

        Graphics g = Graphics.FromImage(img);
        g.SmoothingMode = SmoothingMode.HighQuality;
        g.DrawImage(signature, new Point(0, 0));
        g.Dispose();

        strm.Close();

        if (i == 0)
        {
            String v = Server.MapPath("Image/DB/Large/" + name);
            img.Save(v);
        }

        else if (i == 1)
        {
            String v = Server.MapPath("Image/DB/Slide/" + name);
            img.Save(v);
        }
    }
}  

Excception Details :

[ArgumentException: .] System.Drawing.Image.FromStream(Stream stream, Boolean 
 useEmbeddedColorManagement, Boolean validateImageData) +1065883
 System.Drawing.Image.FromStream(Stream stream) +8 Developer.Page_Load(Object sender, 
 EventArgs e) in f:\.NET Programming\‫FaieqSahwish_V.2.0\Developer.aspx.cs:29
 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t,
 EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
 EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 
 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean
 includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:38:41+00:00Added an answer on June 11, 2026 at 6:38 pm

    According to the FromStream documentation a ArgumentException is thrown if the stream is not a valid image format or if the stream is null.

    Have you verified that neither of these conditions are met for the stream passed into FromStream?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope someone could help me with this: I would like to have a column
I have tried solving this problem by posting other related questions here that focused
I have a very strange problem,I don't know whether it is awkward to normal
hope you can help me! I have a form, which has a large amount
I hope someone can help me with this Javascript. I have an Object called
I have this little code which lists all matches of items that contains the
hope someone can help with this. I currently have an Add to Cart option
I am stuck and in need of a hand. Hope someone can help? Anyone
I'm new here and I hope anyonte can help me. I have WCF Service
I hope I don't lose anyone by mentioning Filemaker. I am trying to turn

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.