Как получить путь с другого компьютера 2 при публикации веб - приложения на компьютере 1
Я публикую(развертываю) свой веб-сайт на IIS
Все работает нормально
Но я генерирую слово с помощью метода поиска и замены (слияние Почты) ,
Из Visual Studio его работа
Но когда я открываю проект с другого компьютера, используя http://192.168.0.101/Electro/SalesInvoice.aspx
это не генерация документа Word
а если мы проверим путь, то он покажет путь вот так ==>
D:ExportToWordExportInvoiceExportSalesInvoiceTamplate.docx
Что я уже пробовал:
protected void tpbtnExportWord_Click(object sender, EventArgs e) { //Finding the FooterTemplate and access its controls Control FooterTemplate = Tprptr.Controls[Tprptr.Controls.Count - 1].Controls[0]; Label lblTotalAfterTax = FooterTemplate.FindControl("tplblTotalAfterTax") as Label; Label TplblTaxableValue = FooterTemplate.FindControl("tplblTaxableValue") as Label; Label TPlblsgst = FooterTemplate.FindControl("tplblsgst") as Label; Label Tplblcgst = FooterTemplate.FindControl("tplblcgst") as Label; Label TPlbligst = FooterTemplate.FindControl("tplbligst") as Label; Label TplblTotalValue = FooterTemplate.FindControl("tplblTotalValue") as Label; //Label TPlblTotalBeforeTax = FooterTemplate.FindControl("tplblTotalBeforeTax") as Label; Label TPlblTotalBeforeTaxValue = FooterTemplate.FindControl("tplblTotalBeforeTaxValue") as Label; Label TPlblTotalinWordValule = FooterTemplate.FindControl("tplblTotalinWordValule") as Label; Label TPtotalTaxValue = FooterTemplate.FindControl("totalTaxValue") as Label; Label TPGstOnReverceChargeValue = FooterTemplate.FindControl("tplblGstOnReverceChargeValue") as Label; objSalesInvoiceBO.TpTotalBeforeTax = Convert.ToDecimal(TplblTaxableValue.Text.ToString()); objSalesInvoiceBO.TpTotalBeforeTax = Convert.ToDecimal(TPlblTotalBeforeTaxValue.Text.ToString()); objSalesInvoiceBO.TpTotalAfterTax = Convert.ToDecimal(lblTotalAfterTax.Text.ToString()); objSalesInvoiceBO.TpGstOnReverceCharge = TPGstOnReverceChargeValue.Text.ToString(); objSalesInvoiceBO.TpSgsttotal = Convert.ToDecimal(TPlblsgst.Text.ToString()); objSalesInvoiceBO.TpCgsttotal = Convert.ToDecimal(Tplblcgst.Text.ToString()); objSalesInvoiceBO.TpIgsttotal = Convert.ToDecimal(TPlbligst.Text.ToString()); objSalesInvoiceBO.TpTotalInWord = TPlblTotalinWordValule.Text.ToString(); objSalesInvoiceBO.TpTotalAfterTax = Convert.ToDecimal(TplblTotalValue.Text.ToString()); #region if (expddlInvoiceTypeCategory.SelectedValue == "1") { object strTemplate = "D:\\ExportToWord\\TAXInvoice\\TaxInvoiceBlank.docx"; strReportPath = "D:\\ExportToWord\\TAXInvoice\\resultt.docx"; try { object missing = System.Reflection.Missing.Value; object outputFileName = strReportPath; object fileFormat; if (File.Exists((string)strTemplate)) { DateTime today = DateTime.Now; object readOnly = false; object isVisible = false; wordApp = new Word.Application(); aDoc = null; wordApp.Visible = false; aDoc = wordApp.Documents.Open(ref strTemplate, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing); aDoc.Activate(); IList<int> lstTableCounts = new List<int>(); for (int i = 1; i <= aDoc.Tables.Count; i++) { Word.Cell cell = aDoc.Tables[i].Cell(1, 1); if (cell.Range.Text.Contains("<lblMultiResults>")) { lstTableCounts.Add(i); } } int[] inttablecounts = lstTableCounts.ToArray(); if (TPInvoiceId == 0) { DataTable dt = new DataTable(); dt = objSalesInvoiceBL.GetTpSalesInvoiceMaxId(); string Maxid = dt.Rows[0][0].ToString(); if (dt.Rows.Count > 0) { objSalesInvoiceBO.TPInvoiceId = Convert.ToInt32(Maxid); } } else { objSalesInvoiceBO.TPInvoiceId = Convert.ToInt32(TPInvoiceId); } //int result = objPurchaseOrderBL.insert_PurchaseMaterialTotal(objPurchaseOrderBO); DataTable dt2 = new DataTable(); DataTable dt4 = new DataTable(); dt2 = objSalesInvoiceBL.Select_TpSalesInvoiceMaterialdetailForPDF(objSalesInvoiceBO); dt4 = objSalesInvoiceBL.Select_TpSalesInvoiceMaterialdetailForSupplierPoNo(objSalesInvoiceBO); if (dt2 != null) { if (dt2.Rows.Count > 0) { #region Code for Multiple Results table foreach (var d in inttablecounts) { string[] strcol; strcol = new string[aDoc.Tables[d].Columns.Count]; for (int i = 1; i <= aDoc.Tables[d].Columns.Count; i++) { Word.Cell cell = aDoc.Tables[d].Cell(3, i); strcol[i - 1] = cell.Range.Text.Replace("\r", "").Replace("\a", ""); } for (int i = 1; i < dt2.Rows.Count; i++) { aDoc.Tables[1].Rows.Add(aDoc.Tables[d].Rows[i + 2]); for (int j = 1; j <= aDoc.Tables[d].Columns.Count; j++) { Word.Cell cell = aDoc.Tables[d].Cell(i + 2, j); cell.Range.Text = strcol[j - 1].Substring(0, strcol[j - 1].Length - 1) + " " + i + ">"; } } for (int i = 1; i <= aDoc.Tables[d].Columns.Count; i++) { Word.Cell cell = aDoc.Tables[d].Cell(dt2.Rows.Count + 2, i); cell.Range.Text = strcol[i - 1].Substring(0, strcol[i - 1].Length - 1) + " " + dt2.Rows.Count + ">"; } try { for (int j = 1; j <= aDoc.Tables[d].Columns.Count; j++) { Word.Cell cell = aDoc.Tables[d].Cell(1, j); cell.Range.Borders[Word.WdBorderType.wdBorderLeft].LineStyle = Word.WdLineStyle.wdLineStyleNone; cell.Range.Borders[Word.WdBorderType.wdBorderRight].LineStyle = Word.WdLineStyle.wdLineStyleNone; cell.Range.Borders[Word.WdBorderType.wdBorderTop].LineStyle = Word.WdLineStyle.wdLineStyleNone; //wdLineStyleSingle } } catch (Exception ex) { } } FindAndReplace(wordApp, "<tinvoiceno>", //P Invoice No dt4.Rows[0]["TpAutoNumber"].ToString()); FindAndReplace(wordApp, "<tinvoicedate>", //date dt4.Rows[0]["TpInvoiceDate"].ToString()); FindAndReplace(wordApp, "<lblMultiResults>", ""); for (int i = 1; i <= dt2.Rows.Count; i++) { FindAndReplace(wordApp, "<mulSrNo " + i + ">", i.ToString()); FindAndReplace(wordApp, "<mulpdescription " + i + ">", dt2.Rows[i - 1]["Product Description HSN/HAC Code"].ToString()); FindAndReplace(wordApp, "<mulpqty " + i + ">", dt2.Rows[i - 1]["Qty(Unit)"].ToString()); } } } if (dt2.Rows[0][0].ToString() == "No") { outputFileName = strTemplate.ToString().Replace(".docx", ".pdf"); fileFormat = Word.WdSaveFormat.wdFormatPDF; } else { fileFormat = Word.WdSaveFormat.wdFormatDocumentDefault; } } else { System.Windows.Forms.MessageBox.Show("File dose not exist."); return; } aDoc.SaveAs(ref outputFileName, ref fileFormat, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); object saveChanges = Word.WdSaveOptions.wdDoNotSaveChanges; aDoc.Close(ref saveChanges, ref missing, ref missing); wordApp.Quit(); System.Diagnostics.Process.Start(@outputFileName.ToString()); } catch (Exception ex) { } } }