/ //****************2013-04-12******************** // //这种方法在服务器端保存图片存在权限问题,已废弃 // // /// <summary> // /// 字节流转换成图片 // /// </summary> // /// <param name="byt">要转换的字节流</param> // /// <returns>转换得到的Image对象</returns> // public System.Drawing.Image BytesToImg(byte[] byt) // { // MemoryStream ms = new MemoryStream(byt); // System.Drawing.Image img = System.Drawing.Image.FromStream(ms); // return img; // } // // //****************2013-04-12******************** public void SavePic(byte[] aImageBytes, string aPicName) { try { string fullName = GetServerName() + "/PartInfo/" +aPicName; if(File.Exists(fullName)) { File.Delete(fullName); } // Image preDrivePic = BytesToImg(aImageBytes); // preDrivePic.Save(fullName,System.Drawing.Imaging.ImageFormat.Jpeg); FileStream fs = new FileStream(fullName, FileMode.Create); //数据保存到磁盘中 BinaryWriter bw = new BinaryWriter(fs); bw.Write(aImageBytes); bw.Flush(); bw.Close(); fs.Close(); GC.Collect(); } catch(Exception ex) { throw new Exception("找不到资源文件夹PadResourceFiles/PartInfo/" + ex.Message); } } private static string GetServerName() { return AppDomain.CurrentDomain.BaseDirectory + "Pad/PadResourceFiles"; }