已搞定!
读:
string str="";
MemoryStream myStream= new MemoryStream();
byte[] mydata=(byte[])dataSet.ItemArray[1];
myStream.Write(mydata,0,mydata.Length);
myStream.Position=0;
StreamReader sr=new StreamReader(myStream);
str=sr.ReadLine();
myStream.Close();
写:
MemoryStream myStream= new MemoryStream();
StreamWriter sw=new StreamWriter(myStream);
sw.WriteLine(str);//str为一传入的字符串
sw.Flush();
byte[] imgdata = myStream.ToArray();
//将imgdata赋值给数据库表中的image 字段即可!