In my MVC application I am trying to open a file for reading through StreamReader, the path the I’ve given to it is this, keeping the relative position of file from bin folder:
TextReader tr = new StreamReader("Content/files/text/email.txt");
But when I’m running it am getting this error over it:
Could not find a part of the path ‘C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\Content\files\text\email.txt.
This is very confusing as I don’t know to how to stop it to stop reading the path from the root directory but read it from application root folder.
You should do this, if you’re talking about winforms application.
UPDATE:
You don’t need StreamReader for a web application. It’s very simple: