I have ac# form application. It opens a text file upon loading. From this text file it reads the default settings. It then fills the numericupdown
fields and textbox
fields with the default data.
I want to run this every night at a specific time. The windows task seems to be trying to open the program. However, upon loading it gets a FileNotFoundException Could not find file 'C:\\Windows\\system32\\Settings.txt
Which is nowhere close to my application run folder. It opens properly when running from command line and using run in MVS2013.
in my program I am searching for this file using relative pathing
could anyone shed some light on this ridiculousness? I would greatly appreciate it.
Your path is relative to the working directory, which seems to be "C:\\Windows\\system32" if you didn't specify any. So possible solutions are, set working directory to the directory of your executable file (the "Start in (optional)" field) :
.. or modify your program to use absolute path of the executable ( you can get the absolute path programmatically ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.