In my C# code, I reference to an XML file \"file.xml\", which is in the same directory as the executable itself, using XmlDocument.
You need to set the application's current working directory to the correct path. I don't know what it is when Task Scheduler launches your application, but it's never a good idea to assume.
You can do so with Directory.SetCurrentDirectory().
Alternatively, you can use an absolute path to the XML file.