本文介绍了找不到网络路径错误未处理IOException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当iam执行iam时出现问题.找不到网络路径
可以提供任何帮助吗,是问题所在..在此先感谢
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.");
}
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);
}
}
public bool IsReusable
{
get { return true; }
}
}
}
推荐答案
这篇关于找不到网络路径错误未处理IOException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!