protected void btnUpload_Click(object sender, EventArgs e) { ResetStatus(); for (int i = 1; i <= 10; i++) { string file_control = "FileUpload" + i.ToString(); string link_button_control = "LinkButton" + i.ToString(); FileUpload fileUpload = (FileUpload)this.Master.FindControl("MainContent").FindControl(file_control); LinkButton linkButton = (LinkButton)this.Master.FindControl("MainContent").FindControl(link_button_control); string label_file_name_control = "LabelFileName" + i.ToString(); Label label_file_name = (Label)this.Master.FindControl("MainContent").FindControl(label_file_name_control); if (fileUpload.PostedFile.FileName != "") { string f_type = Functions.CheckFileType(fileUpload.PostedFile.FileName); string file_name = fileUpload.PostedFile.FileName; if (f_type == "xls" && f_type != "xlsx") { error += "\nFile number " + i.ToString() + " " + file_name + " should be in Excel format!"; linkButton.Visible = true; linkButton.Text = "Error found, click to show error"; } else { DateTime rightnow = DateTime.Now; string user_name = SharedFunctionV3.UserInfo.GetUserInfofromAD(Session["UserID"].ToString()).DisplayName; string new_file_name = Session["UserID"].ToString() + rightnow.ToString("yyyyMMddhhmmss") + "ForecastDataUpload" + i.ToString() + ".xls"; string f_name = Server.MapPath(".") + "\\upload\\" + new_file_name; fileUpload.PostedFile.SaveAs(f_name); label_file_name.Text = f_name; if (CheckFile(f_name, i) == 0)//edited { linkButton.Visible = true; linkButton.Text = "Error found, click to show error"; } else { UploadRecord(f_name, i); } } } } tbError.Text = error; }
if (f_type == "xls" && f_type != "xlsx")
"xls"
"xlsx"
==
!=
string user_name = SharedFunctionV3.UserInfo.GetUserInfofromAD(Session["UserID"].ToString()).DisplayName;
for
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)