File not found using Task Scheduler

c#, scheduled-tasks

Solution

Try to set startup directory for the task. You can set in Task Scheduler.

`Select Task -> Right Click -> Properties -> Actions Tab -> Select Action -> Edit -> Start in (optional)`

Problem

In my C# code, I reference to an XML file "file.xml", which is in the same directory as the executable itself, using XmlDocument. The application runs perfectly well in VS, but when I try to run the application using Task Scheduler, I get a `System.IO.FileNotFoundException`, even though everything's the same. I reference to the file using `@".\file.xml"`. Is this some weird stuff specific to Task Scheduler? Appropriate permissions are used.

Original source