#region 添加图片
[WebMethod(Description = "上传图片")]
public string getImageByte(Byte[] getByte)
{
string savaImageName = null;
try
{
DateTime dt = DateTime.Now;
string sFile = dt.ToShortDateString().ToString();//2005/11/5
String file = "/images/" + sFile;// /images/2005/11/5
if (Directory.Exists(Server.MapPath(file)) == false)//如果文件不存在 则创建
{
Directory.CreateDirectory(Server.MapPath(file));
}
savaImageName = file + "/" + dt.ToFileTime().ToString() + ".png";//127756416859912816
FileStream fs = new FileStream(Server.MapPath(savaImageName), FileMode.Create, FileAccess.Write);
fs.Write(getByte, 0, getByte.Length);
fs.Flush();
fs.Close();
}
catch (Exception e)
{ }
return savaImageName;
}
#endregion
转载于:https://www.cnblogs.com/zzili/archive/2012/12/16/6663215.html