I have a web service web method that accepts an image (as a byte[] array).
[WebMethod]
public string SaveImage(byte[] fs, string fileName)
{
string path = System.Web.HttpContext.Current.Server.MapPath("~") + "/Images/" + fileName;
try
{
MemoryStream ms = new MemoryStream(fs);
//Server.MapPath("~/Images/")
FileStream stream = new FileStream(path, FileMode.CreateNew);
ms.WriteTo(stream);
ms.Close();
stream.Close();
stream.Dispose();
return "OK";
}
catch (Exception ex)
{
string msg = ex.Message.ToString() +
"\n" +
DateTime.Now.ToShortDateString() +
"---" +
DateTime.Now.ToShortTimeString() +
"\n" +
"-----------------------------";
Logger.WriteLog(msg);
return ex.Message;
}
}
I have added correct permissions to the folder, but whatever I try i get the same error,
“Could not find a part of the path c:\inetpub\wwwroot\app\Images”
thanks for the help in advance.
Well after testing a bit there was an issue saving data that came from another platform(android) so i converted the image to a base64 string. And that i converted to an image and successfully saved to the folder.