just copy and past the mention bellow code for details visit http://www.pakistanpassion.com
Code for aspx.cs file
string file;
if (file_upload.HasFile)
{
string filepath = file_upload.PostedFile.FileName;
string file_ext = Path.GetExtension(this.file_upload.PostedFile.FileName);
string filename = Path.GetFileName(this.file_upload.FileName);
string newName = filename.Replace(filename, CompleteName);
string Datenew = DateTime.Now.ToString("g");
DateTime dattime = new DateTime();
dattime = DateTime.Now;
string date = dattime.Date.ToString("d", DateTimeFormatInfo.InvariantInfo);
string[] split;
split = date.Split('/');
string month = split[0];
string day = split[1];
string year = split[2];
string time = dattime.TimeOfDay.ToString();
file = newName + month + "-" + day + "-" + year + file_upload.FileName.ToString() + "";
file_upload.PostedFile.SaveAs(Server.MapPath(@"~/Dynamic/userPics/") + file);
}
No comments:
Post a Comment