I am trying to send image through wcf from my windows application,
See my sample code below:
Windows code:
private void BtnRegister_Click(object sender, EventArgs e)
{
FileStream fs;
byte[] imgByteArrFriends;
RetunImageBytes(PathFriends, out fs, out imgByteArrFriends);
byte[] imgByteArrFamily;
RetunImageBytes(PathFamily, out fs, out imgByteArrFamily);
byte[] imgByteArrLovers;
RetunImageBytes(PathLovers, out fs, out imgByteArrLovers);
byte[] imgByteArrOthers;
RetunImageBytes(PathOthers, out fs, out imgByteArrOthers);
string StatusMessage=ObjProfilePicture.SaveProfilePictures("Eswar", imgByteArrFriends, imgByteArrLovers, imgByteArrFamily, imgByteArrOthers);
}
private void RetunImageBytes(string path,out FileStream fs, out byte[] imgByteArr)
{
imgByteArr = null;
fs = null;
if (path != null)
{
fs = new FileStream(path, FileMode.Open, FileAccess.Read);
imgByteArr = new byte[fs.Length];
fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length));
fs.Close();
}
}
WCF Code:
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
public string SaveProfilePictures(string UserID, byte[] Friends, byte[] Lovers, byte[] Family, byte[] Others)
{
string Message = null;
try
{
objBlobDbConfig.ExecuteCommand(UserID, Friends, Lovers, Family, Others);
Message="Success";
}
catch (Exception ex)
{
Message= "Image Upload Failed.. Please try after sometime";
}
If any body know the solution please help me
What I have tried:
I am trying to send image through wcf from my windows application,
See my sample code below:
Windows code:
private void BtnRegister_Click(object sender, EventArgs e)
{
FileStream fs;
byte[] imgByteArrFriends;
RetunImageBytes(PathFriends, out fs, out imgByteArrFriends);
byte[] imgByteArrFamily;
RetunImageBytes(PathFamily, out fs, out imgByteArrFamily);
byte[] imgByteArrLovers;
RetunImageBytes(PathLovers, out fs, out imgByteArrLovers);
byte[] imgByteArrOthers;
RetunImageBytes(PathOthers, out fs, out imgByteArrOthers);
string StatusMessage=ObjProfilePicture.SaveProfilePictures("Eswar", imgByteArrFriends, imgByteArrLovers, imgByteArrFamily, imgByteArrOthers);
}
private void RetunImageBytes(string path,out FileStream fs, out byte[] imgByteArr)
{
imgByteArr = null;
fs = null;
if (path != null)
{
fs = new FileStream(path, FileMode.Open, FileAccess.Read);
imgByteArr = new byte[fs.Length];
fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length));
fs.Close();
}
}
WCF Code:
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
public string SaveProfilePictures(string UserID, byte[] Friends, byte[] Lovers, byte[] Family, byte[] Others)
{
string Message = null;
try
{
objBlobDbConfig.ExecuteCommand(UserID, Friends, Lovers, Family, Others);
Message="Success";
}
catch (Exception ex)
{
Message= "Image Upload Failed.. Please try after sometime";
}
If any body know the solution please help me