using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Collections.Specialized; private void btnUpload_Click(object sender, System.EventArgs e) { HttpFileCollection files = HttpContext.Current.Request.Files; for(int i = 0; i < files.Count; i++) { if (i { if (files[i].FileName!="" || files[i] != null) { int FileSize = 6*1024*1024; HttpPostedFile myFile = files[i]; string strFilePath = myFile.FileName.ToString().Trim(); this.lblAttachmentError.Text = "<" + strFilePath + ">"; // Show file name int nFindSlashPos = strFilePath.Trim().LastIndexOf("\\")+1; string UploadFileName=strFilePath.Substring(nFindSlashPos); string FileName=this.txtWorkOrder.Text+"_"+string.Format("{0:yyMMdd-hhmmss}",DateTime.Now)+"_"+UploadFileName;
if(myFile.FileName.Trim() == "") // Empty value in Browse Box { this.lblAttachmentError.Text="No file selected."; return; }