110,538
社区成员
发帖
与我相关
我的任务
分享
public Byte[] getphoto(string photopath)
{
string str = photopath;
FileStream file = new FileStream(str, FileMode.Open, FileAccess.Read);
Byte[] bytBLOBData = new Byte[file.Length];
file.Read(bytBLOBData, 0, bytBLOBData.Length);
file.Close();
return bytBLOBData;
}//这是定义函数..
Bitmap bitMap = new Bitmap(filename);
MemoryStream ms = new MemoryStream();
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
xw.Formatting = Formatting.Indented;
XmlSerializer ser = new XmlSerializer(ms.GetBuffer().GetType());
ser.Serialize(xw, ms.GetBuffer());
string xmlString = sw.GetStringBuilder().ToString();
xw.Close();
sw.Close();
ms.Close();
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString);
if (doc != null && doc.ChildNodes.Count > 1 && doc.ChildNodes[1] != null)
{
XmlNode node = doc.ChildNodes[1];
photoString = node.InnerText;
}