本文介绍了找不到网络路径ioexception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它显示在文件流行附近找不到错误的网络路径
有什么可以帮助我的吗?


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.");
        }
        else
        {
            FileStream file = new FileStream(imagePath,FileMode.Open);
            byte[] buffer = new byte[(int)file.Length];
            file.Read(buffer,0,(int)file.Length);
            file.Close();

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

            ////context.Response.AddHeader("content-disposition","attachment
            context.Response.BinaryWrite(buffer);
            context.Response.End();
            //context.Response.Write(imagePath);
            //context.Response.ContentType = "image/" + imageArray[imageArray.Length - 1];
            //context.Response.WriteFile(imagePath);
        }
    }

推荐答案


这篇关于找不到网络路径ioexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 11:34