Bhavesh Vankar

Bhavesh Vankar

  • 763
  • 1.1k
  • 87.9k

How to save image control's image

Oct 29 2020 4:37 AM
how to save image control's image into dynamical directory. code is as below.
using asp.net c# web application. 
  1. string MainDir = @"~/StudentImage/";  
  2.                String SubDir = DateTime.Now.ToString("dd-MM-yyyy");  
  3.                if (!Directory.Exists(Server.MapPath(MainDir)))  
  4.                {  
  5.                    Directory.CreateDirectory(Server.MapPath(MainDir));  
  6.                }  
  7.                if (!Directory.Exists(Server.MapPath(MainDir + SubDir)))  
  8.                {  
  9.                    Directory.CreateDirectory(Server.MapPath(MainDir + SubDir));  
  10.                }  
  11.                vImage.ImageUrl = Server.MapPath(MainDir + SubDir);  
  12.                string imgname = Path.GetFileName(vImage.ImageUrl);  
  13.                vImage.ImageUrl=(Server.MapPath(MainDir + imgname));  
i have tried but still not working... 

Answers (8)