您必须为每个图像添加流转换并将详细信息添加到列表中。
在客户端。
Stream stream = (Stream)openDialog.File.OpenRead();
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, (int)stream.Length);
BitmapImage bmi = new BitmapImage();
using (MemoryStream ms = new MemoryStream(bytes))
{
bmi.SetSource(ms);
newRow.Thumbnail = bmi;
}
在您的服务方面
string filePath = ConfigurationManager.AppSettings.Get("ImageUploadPath");
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
filePath = filePath + "\\" + picture.FileName + "." + picture.FileType;
if (picture.FileName != string.Empty)
{
fileStream = File.Open(filePath, FileMode.Create);
writer = new BinaryWriter(fileStream);
writer.Write(picture.FileStream);
}