c# - How do I store Excel File without getting the warning -
i trying replace file gives me warning:
the file exists. want replace file
in code, not want warning
code:
string fromfile = @"\\test.net\excel\123.xls"; string tofile = @"\\test.net\excel\123.xls"; microsoft.office.interop.excel.application app = new microsoft.office.interop.excel.application(); microsoft.office.interop.excel.workbook wb = app.workbooks.open(fromfile, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing); file.delete(tofile); wb.saveas(tofile, microsoft.office.interop.excel.xlfileformat.xlworkbookdefault, type.missing, type.missing, false, false, microsoft.office.interop.excel.xlsaveasaccessmode.xlexclusive, microsoft.office.interop.excel.xlsaveconflictresolution.xllocalsessionchanges, false, type.missing, type.missing, type.missing); wb.close(false, type.missing, type.missing); app.quit();
add
app.displayalerts = false;
before saveas
call , add
app.displayalerts = true;
after close
event.