Click here to Skip to main content
15,116,653 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When iam executing iam getting the problem. the network path was not found
can any help was the problem is..thanks in advance
public void ProcessRequest(HttpContext context)
            string imagePath = context.Request.QueryString["image"];

            // split the string on periods and read the last element, this is to ensure we have
            // the right ContentType if the file is named something like "image1.jpg.png"
            string[] imageArray = imagePath.Split('.');

            if (imageArray.Length <= 1)
                throw new HttpException(404, "Invalid photo name.");
                FileStream file = new FileStream(imagePath,FileMode.Open);
                byte[] buffer = new byte[(int)file.Length];

                context.Response.ContentType = "application/octet-stream";

                //context.Response.ContentType = "image/" + imageArray[imageArray.Length - 1];

        public bool IsReusable
            get { return true; }

Updated 5-Oct-12 6:00am
priyanka Dhoble 5-Oct-12 10:36am
Where is the image file stored on client or server? And what is the value of imagePath?

1 solution

There is no problem with the code.

The problem is in tour image file name along with the path.

So, you check what the value is return from the querystring["image"]
and check whether you ca access it in file explorer.

I am sure, the path you passed in querystring is invalid. So, resolving this will make your program run with no issues.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900