public void create_db_file(List<V_xiaopian> list, string wjj,string yp_bh,long qs_id)
{
var new_yp_id = int.Parse(yp_bh.Split('Y')[1]);
string FileSavePath = wjj + "\\" + "Q" + qs_id + "Y" + new_yp_id + ".xls";
DataTable ds = Pub.ListToDataTable(re_list);
ExcelHelper.DataTableToExcel(ds, "Sheet1", FileSavePath, true);
//string FileSavePath = wjj + "\\" + "Q" + qs_id + "Y" + new_yp_id + ".xlsx";
// 获取现在文件名
string currentFileName = Path.GetFileName(FileSavePath);
// 获取现在文件路径
string directoryPath = Path.GetDirectoryName(FileSavePath);
// 改名字
string newFileName = Path.ChangeExtension(currentFileName, ".xlsx");
// 重新结合
string newFilePath = Path.Combine(directoryPath, newFileName);
// 是否存在
if (File.Exists(newFilePath))
{
File.Delete(newFilePath);
}
File.Move(FileSavePath, newFilePath);
//Console.WriteLine("文件已成功重命名为:" + newFilePath);
}
10-23
2248
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-20
332
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)