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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:42:57+00:00 2026-06-02T12:42:57+00:00

I am writing a little project to parse a CSS file, and base64 encode

  • 0

I am writing a little project to parse a CSS file, and base64 encode all the background images.

While I am able to parse the CSS correctly, it seems that everytime I try to convert the image file into a base64Encoded string, the string returned is always exactly the same.

What am I doing wrong?

Here’s the encoder. Please assume that all image paths are passing correctly to the method. In this instance, all images are fully qualified urls, so the first section of the method is what is doing the conversion.

Public Sub EncodeImage(ByVal _File As String)
    If _File.StartsWith("http") OrElse _File.StartsWith("https") Then
        Using _wc As New WebClient()
            Common.SetAllowUnsafeHeaderParsing20()
            _wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13")
            _wc.DownloadFile(_File, "c:\temp.png")
            Dim _d As Byte() = _wc.DownloadData(_File)
            ImageStrings.Add(New ImageTyping() With {
                             .SourceFile = _File,
                             .Base64String = Convert.ToBase64String(_d)
                         })
            _d = Nothing
        End Using
    Else
        Using _fs As New FileStream(_File, IO.FileMode.Open)
            Using _br As New BinaryReader(_fs)
                Dim _i As Byte() = _br.ReadBytes(_fs.Length)
                ImageStrings.Add(New ImageTyping() With {
                             .SourceFile = _File,
                             .Base64String = Convert.ToBase64String(_i)
                             })
                _i = Nothing
                _br.Close()
            End Using
            _fs.Close()
        End Using
    End If
End Sub

Each and every string returned from this is: iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAAGXcA1uAAAAKUlEQVRIx2P4//+/DwwzUJUzoiRGNYxqGNUwGDSMWjBqwagFoxbQAAMAfS9kqktT8qQAAAAASUVORK5CYII=

  • 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-06-02T12:42:58+00:00Added an answer on June 2, 2026 at 12:42 pm

    I removed the User-Agent header string, and the problem went away.

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

Sidebar

Related Questions

I'm working on a little project where I'd like to parse some data, and
To give a little background, I'm writing (or am going to write) a daemon
A little background : I'm writing a set of C# classes to wrap a
I am currently writing a little helper-app for my big WinForms-Project. In this little
I've been slowly writing a little project to create a Movie/TV Show/Music ID3 tag
I have a little project I am working. I am writing django database to
Ok, so coming from a background of mostly perl, and mostly writing dirty little
Hello I'm writing a little project in c++ where I would like to have
I'm writing a little browser game as a project to learn RoR with and
I've been writing a blog as a learning project for a while now and

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.