c# - Getting "Cannot access file exception -
i getting following exception. "comexception unhandled" "can not access file_name.xls"
string currentdir=directory.getcurrentdirectory(); if (defaultbuttonclicked) { _csvfilepath = path.combine(currentdir, "file name_" + datetime.now.adddays(-1).tostring("mm-dd-yyyy") + ".xls"); defaultbuttonclicked = false; } else if (datespecificsearchbuttonclicked) { var datetemp = calchoosedate.value.tostring("mm-dd-yyyy"); _csvfilepath = path.combine(currentdir, "file name_" + datetemp + ".xls"); datespecificsearchbuttonclicked = false; } workbook.saveas(_csvfilepath, excel.xlfileformat.xlopenxmlworkbook, type.missing, type.missing, true, false, excel.xlsaveasaccessmode.xlnochange, type.missing, type.missing, type.missing, type.missing, type.missing); workbook.close(true, misvalue, misvalue); system.runtime.interopservices.marshal.releasecomobject(application)
Comments
Post a Comment