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 7564119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:50:10+00:00 2026-05-30T13:50:10+00:00

Got a big issue with memorystream in c#. My application gets the html of

  • 0

Got a big issue with memorystream in c#. My application gets the html of an email, and parses the src values of the images that are attachments and change those src values to another ones. That works perfectly fine. Problem is i have to save the resultant html in a sharepoint list. and it does, but when i see the content in the sharepoint list, it doesnt show the email, just some part of it. I dont know if the memory stream is not saving the content at all, or if the string am saving the result doesnt have enough capacity for saving what the memory stream is storing. If anyone has any ideas please post them!

string SRC = "";
int indice = 0;
//Console.WriteLine(body);

HtmlDocument email = new HtmlDocument();
email.LoadHtml(body);
Console.WriteLine("bodylength: " + body.Length);//original length

foreach (HtmlNode img in email.DocumentNode.SelectNodes("//img"))
{
    SRC = img.GetAttributeValue("src", null);
    for (int i = 0; i < contentIDS.Count; i++)
    {
        if (SRC.Equals(contentIDS[i].ToString()))
        {
            //Console.WriteLine("contents" + contentIDS[i].ToString());
            indice = i;
            break;
        }
    }
    img.SetAttributeValue("src", urls[indice].ToString());
    Console.WriteLine(img.GetAttributeValue("src", null));
}

//se guarda en memoria los cambios hechos en el html y se retorna e tipo string el html con los cambios realizados
MemoryStream memoryStream = new MemoryStream();
email.Save(memoryStream);
//memoryStream.SetLength(body.Length);
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
StreamReader streamReader = new StreamReader(memoryStream);
return streamReader.ReadToEnd();//this is then store in a string when i call this method. The lenght of that string is much much smaller than the original one.
  • 1 1 Answer
  • 0 Views
  • 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-30T13:50:12+00:00Added an answer on May 30, 2026 at 1:50 pm

    You can simplify this by using a Save overload which uses a TextWriter:

    HtmlDocument email = new HtmlDocument();
    using (var sw = new StringWriter())
    {
        email.Save(sw);
        return sw.ToString();
    }
    

    Note that you should always dispose objects which implement IDisposable (the simplest way is to wrap them inside using blocks as shown here).

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

Sidebar

Related Questions

I've got a big big code base that includes two main namespaces: the engine
I've got a big Windows legacy application composed by many executables interacting with a
I've got a big multi-module project, and I'd like to generate a report that
I've got one really big .java class file that has a lot of members.
I've got several tables that I want to merge for one big query. The
I just got a mail saying that I have to change a config value
I got a simple setup (and a big issue): a JSP page with en
I got a big issue when trying to parse json data in xcode. I
I got one big question. I got a linq query to put it simply
So I've got a big text file which looks like the following: <option value

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.