1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| [WebMethod()]
public byte[] GetFile(string fileName)
{
byte[] response;
string filePath = @"D:\client\" + fileName;
response = File.ReadAllBytes(filePath);
return response;
du coté client mon code est le suivant avec comme exemple une image .png
String fileName = "add.png";
SendToServer myservice = new SendToServer();
byte[] response = myservice.GetFile(fileName);
MemoryStream memory = new MemoryStream(response);
// Display the file in a picture box.
PictureBox pictureBox1 = new PictureBox();
pictureBox1.Image = System.Drawing.Image.FromStream(memory); |