Reputation: 13610
In my bin file I have set up som test data, and I want my application to be able to access logfiles that are stored in bin/log/log00001.txt
.
However, in my crontroller, when I try to use a TextReader on the following path it goes somewhere else: new StreamReader("log/log00001.txt")
How do I read stuff relative to my project?
Upvotes: 8
Views: 5549
Reputation: 1879
Try using
StreamReader reader = new StreamReader(Server.MapPath("~/bin/log/log00001.txt"));
Upvotes: 13
Reputation: 120450
HttpContext.Current.Server.MapPath("~/some/path/relative/to/your/web/app")
Upvotes: 6