private void AddImage(object obj) { Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog { FileName = "Document", DefaultExt = ".png", Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif" }; bool?result = openFileDialog.ShowDialog(); if (result == true) { this.ImageName = openFileDialog.SafeFileName; var avatar = System.Drawing.Image.FromFile(openFileDialog.FileName); this.newProfilePicture = new ProfileImageModel() { Content = facade.ConvertImageToByteArray(avatar), PictureFormat = facade.ConvertFileExtenstionToEnum(openFileDialog.DefaultExt), FileName = openFileDialog.SafeFileName, Id = Model.ProfilePicture.Id }; } }