I made a program in which part of the program is supposed to open a local csv file. The program works flawlessly when I double click it and run it locally.

However, I wanted this program to run every hour so used Windows 10 Task Scheduler to do that. When the task scheduler executes the program, the program throws an error saying it can’t open that local csv file. But it works fine when I run the program manually.
What gives?

Is the local csv file in a directory related to the EXE file? There is probably a pathing issue as the scheduler may run it under a different path.
Could also be a permission error, the scheduler could run under a different privilege level.
ahhh…

In Task Scheduler I changed the “start in” setting to be the path where the program is located. Now it works.
Didn’t think that setting mattered.

The execution path of a service runs relative to the windows/system directory, if I remember right. Always have to reference it absolute, or by the config you stated (start in).
Hah! I literally ran into the same issue just yesterday
C# devs
null reference exceptions

source