1
My question is the same as the title: how to create a variable that points to the Content folder?
I have a file there and I want to access it. I tried so but unsuccessfully:
StreamReader file =
new StreamReader(@"~/Content/tb_ocupacao.txt", Encoding.GetEncoding("iso-8859-1"));
Which library I have to import to recognize
Server
?– Italo Rodrigo
None. That’s from namespace
System.Web
.– Jéf Bueno
I want to use this code in a class, I’m already using the
System.Web
, even so Server is not being recognized. Some other tip?– Italo Rodrigo
This code needs to be in a request
– Jéf Bueno
@Italorodrigo you should have specified this in your question, if you can use it like this:
System.Web.HttpContext.Current.Server.MapPath
– novic
@Virgilionovic worked, thanks. Sorry if I didn’t specify well, I’m still learning MVC.
– Italo Rodrigo
@Virgilionovic will post an answer? Because if not, I will edit mine to not be incomplete.
– Jéf Bueno
@LINQ can use the comment without problems! vlw
– novic