Click here to Skip to main content
15,069,133 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Its showing error network path was not found near filestream line
can any help me plz

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];

1 solution

The error is quite explicit: "network path was not found" means just that: it cannot find the file you are trying to open.

Check your name, and make sure that it is an absolute address - if it is not, then it will be relative to the aspx file being executed.

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