Hello everyone, hope someone can give me the correct code.
I am trying to print a RDLC report without preview. Below is my code but does not work. The error says "Exception Details: System.NotSupportedException: The given path's format is not supported."
- protected void PrintPos(object sender, EventArgs e)
- {
- string sql = "spGet_SalesDetails_A4Printing";
- var dt = GetDataTable(sql);
- LocalReport report = new LocalReport();
- string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
- string fullpath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Remove(path.Length - 4) + @"\PosPrinting\PrintingPos.rdlc";
- report.ReportPath = fullpath;
- report.DataSources.Add(new ReportDataSource("dsProduct", dt));
- int printQty = 2;
- for(int i = 0; i < printQty; i++)
- {
- PrintToPrinter(report);
- }
- }
I am following this post: https://ashproghelp.blogspot.com/2017/01/how-to-print-directly-without-showing.html