Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 809903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:48:06+00:00 2026-05-15T00:48:06+00:00

i have some html files as part of a regular website that has been

  • 0

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.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:48:07+00:00Added an answer on May 15, 2026 at 12:48 am

    If it were me, I would store the information in a database. It’e much easier that way and, from my perspective, it little matters whether the disk space is consumed on the database server or the web server. If, on the other hand, the files are relatively static — i.e., lots of reads but only few writes and they are common to all users (site files not per-user files), then you could consider putting them in the Content directory. I often create a subdirectory in Content named static for just such files, though I don’t usually provide a way to edit them from the site (editable content would go in the DB). This way you can construct a path to them.

    For what it’s worth, you should probably just open the path and read them, rather than using a WebClient.

        string url = Url.Content( "~/content/newsletters/test.html" );
        string path = Server.MapPath( url );
        StreamReader sr = new StreamReader(path);
        string htmlData_ = sr.ReadToEnd();
    

    Note: you may have to create the UrlHelper, I don’t think its a property on the Controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET console application that needs to generate some HTML files. I
I have some html files that I want to convert to text. I have
I have some static resources (images and HTML files) that will be localized. One
I'm developing a page in asp.net/C# that displays files and HTML pages from a
I have some html files with their own css. I want to use them
I use DOMDocument for editing some HTML files, but some of theme have in
I have such files to parse (from scrapping) with Python: some HTML and JS
I have a series of files containing html comments ( <!-- some comment -->
How to find all files in directory? I have HTML page in some directory.
I have this html file where I want to overlay some text over another.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.