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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:45:58+00:00 2026-05-24T07:45:58+00:00

I have a stream that is reading the response from a site. I am

  • 0

I have a stream that is reading the response from a site. I am then saving that stream to text in a text file.

If I then run it again and compare the string from the same site and the text saved in the file it thinks they are different.

When I compare the two strings in a diff tool like WinMerge it find differences at apparently identical points.

What is happening? They are both using the default UTF8 encoder.

I appreciate this may be difficult to follow so I have written a working example for you.

Here is an example:

        var request = WebRequest.Create("http://www.google.com");
        using (var response = request.GetResponse())
        using (var body = response.GetResponseStream())
        using (var googReader = new StreamReader(body))
        using (var googFileStream = File.Open("goog.txt", FileMode.OpenOrCreate))
        using (var fileReader = new StreamReader(googFileStream))
        {
            var googText = googReader.ReadToEnd();
            var fileText = fileReader.ReadToEnd();
            if (!string.Equals(googText, fileText))
            {
                googFileStream.Dispose();
                using (var msnWriter = new StreamWriter(File.Open("goog.txt", FileMode.Create)))
                {
                    msnWriter.Write(googText);
                }
            }
        }

Here is the apparent ‘difference’ as reported by WinMerge. It is apparently at the point between html; charset:
Diff of the two strings

  • 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-24T07:45:59+00:00Added an answer on May 24, 2026 at 7:45 am

    Your code seems fine. It’s just that Google actually returns different contents every time you send a request to it. Other than that you might try simplifying your code and use a site which doesn’t return different contents everytime:

    var file = "goog.txt";
    using (var client = new WebClient())
    {
        var data = client.DownloadString("http://www.google.com");
        if (!File.Exists(file) || !string.Equals(File.ReadAllText(file), data))
        {
            File.WriteAllText(file, data);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have response stream from a ftp web request that returns binary file. I
I have a servlet that construct response to a media file request by reading
I have a thread reading data from a bluetooth stream that sends the data
I have created a few small flash widgets that stream .mp3 audio from an
I often run into the problem that I have one stream full of data
I have a dynamically created image that I am saving to a stream so
In my code, I have a load_dataset function that reads a text file and
I have an iterator (actually a Source.getLines ) that's reading an infinite stream of
I have a data stream that may contain \r, \n, \r\n, \n\r or any
I have a byte stream that may be UTF-8 data or it may be

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.