如何将水晶报表转换为.pdf而不替换以前的.pdf文件?我确实把“小时,分钟,秒”放了,但它仍然取代了前一个。感谢。
//String reportDate = dt.Year.ToString() + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0');
String reportPrefix = dt.Year.ToString() + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0') + dt.Hour.ToString().PadLeft(2, '0') + dt.Minute.ToString().PadLeft(2, '0') + dt.Second.ToString().PadLeft(2, '0') + dt.Millisecond.ToString();
String report = Report + "BillingReport-" + reportPrefix + ".pdf";
crRpt.ExportToDisk(ExportFormatType.PortableDocFormat, report);
Console.WriteLine("" + report + " " + DateTime.Now.ToLongTimeString());
答案 0 :(得分:0)
您可以使用GUID或DateTime.Now中的Ticks。
或者,如果先前找到了文件,则可以添加索引:
String reportPrefix = Report + "BillingReport-" + dt.Year.ToString() + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0') + dt.Hour.ToString().PadLeft(2, '0') + dt.Minute.ToString().PadLeft(2, '0') + dt.Second.ToString().PadLeft(2, '0') + dt.Millisecond.ToString();
String report;
bool fDone = false;
int wIndex = 0;
// Cycle looking for the first file that doesn't exist
do while (!fDone) {
report = reportPrefix;
// Include the index once we have checked the base file name
if (wIndex > 0)
{
report += wIndex.ToString();
}
report += ".pdf";
if (System.IO.File.Exists(report))
{
// If the file exists, increment the index and keep looking
wIndex++;
} else {
// Otherwise, we are done
fDone = true;
}
}