I have created a console app that I am trying to run in Task Scheduler. When I run it by clicking the executable or using a shortcut it works fine but when I run it in Task Scheduler I get "The app for PHLIP231 Prod had Access to the path 'C:\WINDOWS\DMBErrors' is denied."
I have searched my app for this path and have even tried manually adding the path to my computer with no success. My app builds an excel file and writes it to a path relative to the executable.
This is the code I use for doing this:
string strFileName = "";
string strCurrentDirectory = Path.GetDirectoryName(Environment.CurrentDirectory);
string strDMBErrors = Path.Combine(strCurrentDirectory, "DMBErrors");
DirectoryInfo directory = new DirectoryInfo(strDMBErrors);
if (!Directory.Exists(strDMBErrors))
{
Directory.CreateDirectory(strDMBErrors);
}
strFileName = strDMBErrors + "\\PHLIP251ErrorsProd" + strDate2 + Sender + ".xls";
excelApp.ActiveWorkbook.SaveAs(strFileName);
Any help would be appreciated. Thanks.