protected void btnAdd_Click(Object Sender, EventArgs e) { string strPath = lblPath.Text; if (txtFile.FileName != "" && txtFile.PostedFile != null) { string strDirectory = oVariable.DocumentsFolder() + "scripts"; if (Directory.Exists(strDirectory) == false) { Directory.CreateDirectory(strDirectory); } string strFile = txtFile.PostedFile.FileName.Trim(); string strFileName = strFile.Substring(strFile.LastIndexOf("\\") + 1); if (File.Exists(strDirectory + "\\" + strFileName) == true) { int intFileCount = 1; string strFileCount = strFileName + ".VERSION_" + intFileCount.ToString(); while (File.Exists(strDirectory + "\\" + strFileCount) == true) { intFileCount++; strFileCount = strFileName + ".VERSION_" + intFileCount.ToString(); } File.Move(strDirectory + "\\" + strFileName, strDirectory + "\\" + strFileCount); } strPath = strDirectory + "\\" + strFileName; txtFile.PostedFile.SaveAs(strPath); } int intLanguage = 0; Int32.TryParse(ddlLanguage.SelectedItem.Value, out intLanguage); int intTimeout = 0; Int32.TryParse(txtTimeout.Text, out intTimeout); if (intID == 0) { oAudit.AddScript(txtName.Text, ddlHardcode.SelectedItem.Value, (radLocal.Checked ? 1 : 0), intLanguage, strPath, txtParameters.Text, intTimeout, (chkEnabled.Checked ? 1 : 0)); } else { oAudit.UpdateScript(intID, txtName.Text, ddlHardcode.SelectedItem.Value, (radLocal.Checked ? 1 : 0), intLanguage, strPath, txtParameters.Text, intTimeout, (chkEnabled.Checked ? 1 : 0)); } Response.Redirect(Request.Path); }