public ResponseModel BulkUploadAlert() { SettingsCaller newAlert = new SettingsCaller(); ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; string fileName = ""; string finalAttchment = ""; string timeStamp = DateTime.Now.ToString("ddmmyyyyhhssfff"); DataSet dataSetCSV = new DataSet(); string[] filesName = null; try { var files = Request.Form.Files; string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); #region Read from Form if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { fileName += files[i].FileName.Replace(".", "_" + authenticate.UserMasterID + "_" + timeStamp + ".") + ","; } finalAttchment = fileName.TrimEnd(','); } var exePath = Path.GetDirectoryName(System.Reflection .Assembly.GetExecutingAssembly().CodeBase); Regex appPathMatcher = new Regex(@"(?<!fil)[A-Za-z]:\\+[\S\s]*?(?=\\+bin)"); var appRoot = appPathMatcher.Match(exePath).Value; //string Folderpath = appRoot + "\\" + "BulkUpload"; string Folderpath = appRoot + "\\" + "BulkUpload" + "\\" + "Alert"; if (files.Count > 0) { filesName = finalAttchment.Split(","); for (int i = 0; i < files.Count; i++) { using (var ms = new MemoryStream()) { files[i].CopyTo(ms); var fileBytes = ms.ToArray(); MemoryStream msfile = new MemoryStream(fileBytes); FileStream docFile = new FileStream(Folderpath + "\\" + filesName[i], FileMode.Create, FileAccess.Write); msfile.WriteTo(docFile); docFile.Close(); ms.Close(); msfile.Close(); } } } dataSetCSV = CommonService.csvToDataSet(Folderpath + "\\" + filesName[0]); #endregion // dataSetCSV = CommonService.csvToDataSet("D:\\TP\\hierarchymaster.csv"); int result = newAlert.AlertBulkUpload(new AlertService(Cache, Db), authenticate.TenantId, authenticate.UserMasterID, dataSetCSV); statusCode = result > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = result; } catch (Exception) { throw; } return(objResponseModel); }