导出到磁盘抛出错误'系统找不到指定的路径'
本文关键字:找不到 路径 系统 出错 错误 磁盘 | 更新日期: 2023-09-27 18:09:18
我使用以下代码导出pdf格式的水晶报告。
if (textBox1.Text == "" | textBox2.Text == "")
{
}
else
{
string filename = "''" + textBox1.Text + ".pdf";
CreateEmptyFile(filename);
string file = textBox2.Text + "''" + textBox1.Text + ".pdf";
labelget();
try
{
int idx = dataGridView1.CurrentCell.RowIndex;
string parv = dataGridView1.Rows[idx].Cells[0].FormattedValue.ToString();
ReportDocument wordreport = new ReportDocument();
wordreport.Load(@"C:''FOLDER''TESTREPORT.rpt");
wordreport.SetDatabaseLogon("root", "xxxxxxx", localhost, database);
wordreport.Refresh();
wordreport.SetParameterValue("bill_no", parv);
wordreport.SetParameterValue("fromterminal", this.terminal);
wordreport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, file);
}
catch (Exception em)
{
MessageBox.Show("error is: " + em);
}
}
wordreport.ExportToDisk
行出现错误,系统无法找到指定的路径。我检查了我创建PDF文件的路径的权限,一切看起来都很好。我如何纠正这个错误?
我找到了问题的原因和答案。我错过了在管理工具中添加DSN细节。