2
I’m trying to get an image that is inside a folder in the project to use with "Default" if any user does not add the photo at the time of registration, but when trying to pass the url, the error because I.o cannot find the same one.
Follow image location in the project:
Per line of code, I managed to pass like this:
if (usuario.imagem.Length == 0)
{
string path = @"C:\Pro\028\webIRMA\Content\dist\img\avatarPadrao.png";
using (Image image = Image.FromFile(path))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();;
Session["ImagePerfil"] = imageBytes;
}
}
}
else
{
Session["ImagePerfil"] = usuario.imagem;
}
But this is localhost
, when it is passed to another server, in the case of production can change the site of the project,then tried something as below, but without success:
string path = @"~/webIRMA/Content/dist/img/avatarPadrao.png";