File not found using Task Scheduler

后端 未结 4 1345
甜味超标
甜味超标 2020-12-30 10:59

In my C# code, I reference to an XML file \"file.xml\", which is in the same directory as the executable itself, using XmlDocument.

4条回答
  •  清歌不尽
    2020-12-30 11:17

    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.

提交回复
热议问题