I have got this read file code from microsoft
@"C:\Users\computing\Documents\mikec\assignment2\task_2.txt"
That works fine when im working on it, but when i am to hand in this assignment my lecturer isn’t going to have the same directory as me.
So i was wondering if there is a way to read it from just the file the program is held in?.
I was thinking i could add it as a resource but im not sure if that is the correct way for the assignment it is meant to allow in any file.
Thanks
You can skip the path – this will read file from the working directory of the program.
Just
@"task_2.txt"will do.UPDATE: Please note that method won’t work in some circumstances. If your lecturer uses some automated runner (script, application whatsoever) to verify your app then @ken2k’s solution will be much more robust.