Referencing View directory in asp.net mvc

Posted by ooo on Stack Overflow See other posts from Stack Overflow or by ooo
Published on 2010-05-26T12:23:20Z Indexed on 2010/05/26 12:41 UTC
Read the original article Hit count: 249

Filed under:
|

i have some html files as part of a regular website that has been ported over to asp.net mvc. In my code i need to read and write these html files and stick them in a tinymce editor

To be able to read and write this file from disk in the past i had a hard coded path but this doesn't seem to work in asp.net mvc unless i do something like this:

Writing:

    string _urlDirectory = @"c:\hosting\MySite\Views\Members\newsletters\test.html";
    System.IO.File.WriteAllText(_urlDirectory, htmlData_);

Reading:

        string url = @"c:\hosting\MySite\Views\Members\newsletters\test.html";
        var req = WebRequest.Create(url);
        var response = req.GetResponse();
        StreamReader sr = new StreamReader(response.GetResponseStream());
        string htmlData_ = sr.ReadToEnd();

i am moving my site from one data center to another and the directory structure is changing. instead of just changing the hard coded path to another hard coded path i wanted to see if there was a more relative way to reference these files.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about directories