I am trying to save my Excel file that I created in c#. I added a DateTime.Now to the title and made sure the characters where compatible. Now I have the above error when the folder exists. I have posted what it says could be the error but none apply. Also when I get the error it tells me the DateTime.Now portion is say for todays date and time started was 5/9/8E017700. That is not not a date or time for year and time. I think that maybe the problem but I am unsure as to why it is altered when I never change the variable for name. How can I get this problem resolved?
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
string date = DateTime.Now.ToString().Replace(":", ".");
string filename = "IncomingProduct-" + date + ".xls";
string subPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/Documents/Reports/";
bool isExists = Directory.Exists(subPath);
if (!isExists)
Directory.CreateDirectory(subPath);
xlWorkBook.SaveAs(subPath + filename);//error here
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
System.Diagnostics.Process.Start(subPath + filename);
xlWorkBook.SaveAsline, and examine the contents ofsubPathandfileName. What exactly are the values of those variables when your code is executed?