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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:53:55+00:00 2026-06-16T20:53:55+00:00

I seem to be having some issues with a Filestream in C#. I am

  • 0

I seem to be having some issues with a Filestream in C#.
I am trying to read the last line from a VERY large text file, 10mb, that is generated by a MSI installer.

The code I am using is:

string path = @"C:\uninstall.log";
byte[] buffer = new byte[100];

using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
    long len = fs.Length;

    fs.Seek(-100, SeekOrigin.End);

    fs.Read(buffer, 0, 100);
}

string foo = Encoding.UTF8.GetString(buffer);
Console.WriteLine("\"" + foo + "\"");

But the output looks similar to this:

H E L L O   W O R L D ! ! ! B L A H   B L A H

Apparently the stream that is read contains a ‘\0’ (null) character every other character.
Does anyone know what is causing this?

  • 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-16T20:53:56+00:00Added an answer on June 16, 2026 at 8:53 pm

    Use Encoding.UnicodeEncoding instead. Your file is encoded in UTF-16, not UTF-8.

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

Sidebar

Related Questions

I installed scala 2.8.0 last night and I seem to be having some issues
I'm having some issues with loading a (.properties) file from the webcontent folder in
I seem to be having some issues with my domain controller when trying to
Seem to be having some issues storing the current date in a core data
I'm having some issues with a report I'm trying to create for TFS work
I'm having some performance issues calling CGContextDrawLayerAtPoint in iOS 4 that didn't seem to
I seem to be having some issues while attempting to implement logging into my
Evening guys, This may seem like a stupid question but im having some issues
I'm having some issues trying to setup my Routing in MVC. I think I
Im having some issues trying to adjust the Width of some of the items

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.