服务器中文件路径在C++ Builder 6中应该如何格式存储才稳定?
我将文件路径存于数据库中,在C++ Builder 5中运行正常,可是在C++ Builder 6中却不稳定,有时正常,有时不正常,不知什么原因,在C++ Builder 6应该以什么格式存储?下面是源程序,那位高手分析一下。
ReportDate=zYear+zMonth+zDay;
ReportPath=ReportQ->FieldByName("SearchTablePath")->AsString;// SearchTablePath为数据表的Varchar字段,存于表中。格式为:\\chxl10\finance\report\,其中chxl10为服务器名称,finance,report为文件夹名称。
ReportFileName=ReportQ->FieldByName("SearchTableName")->AsString;
ReportFile=ReportPath+ReportFileName+ReportDate+".xls";
ReportFile=ReportFile.c_str();
if (FileExists(ReportFile))//此处有时判断为有,有时判断为无。如将SearchTablePath字段输为:D:\\ finance\\report\\格式就不会出现不稳定问题。一直判断为有。但此种格式在转到Excei 时又有问题。
{
SelectedTreeNode->ImageIndex=1;
SelectedTreeNode->SelectedIndex=1;
}
else
{
SelectedTreeNode->ImageIndex=2;
SelectedTreeNode->SelectedIndex=2;
}
}
break;
// ReportPath=" d:\\ finance\\report\\";
ReportFile=ReportPath+ReportFileName+ReportDate+".xls";
if (FileExists(ReportFile))
{
int i,j;
Ex=Variant::CreateObject("Excel.Application");
Ex.OlePropertySet("Visible",true);
Ex.OlePropertyGet("WorkBooks").OleProcedure("Open",ReportFile.c_str());//如果ReportPath取表中数据,不管表中是\\chxl10\finance\report\或d:\\ finance\\report\\格式,程序执行到此处都要出错,只有将语句改为ReportPath=" d:\\ finance\\report\\";就没有问题,很稳定运行。
Wb=Ex.OlePropertyGet("ActiveWorkBook");
Variant Sh1=Wb.OlePropertyGet("Sheets");
Sh=Sh1.OlePropertyGet("Item",1);
Sh.OlePropertyGet("Activate");