private bool UploadProfilePic(string ProfilePicURL, int?UserID) { bool flag = false; string fname = DateTime.Now.ToString("yyyyMMddhhmmss"); string ext = Path.GetExtension(ProfilePicURL); var path = Path.Combine(Server.MapPath("/Document/" + UserID + "/")); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(ProfilePicURL); HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); Stream receiveStream = httpWebResponse.GetResponseStream(); Image imageFB = Image.FromStream(receiveStream); string fileName = Path.Combine(path, fname + ext); imageFB.Save(fileName); ResizeImage img = new ResizeImage(); Bitmap image = new Bitmap(path + fname + ext); string file_81x81 = path + fname + "_81x81" + ext; Bitmap b_81x81 = img.ResizeBitmap(image, 81, 81); img.saveJpg(file_81x81, b_81x81, 100); Employee emp = db.EmployeeDB.Find(UserID); emp.Logo = fname + ext; db.SaveChanges(); flag = true; return(flag); }