Read ASCII string from byte buffer

image_pdfimage_print


   
 

using System;
using System.Globalization;
using System.Windows.Forms;
using System.Data;
using System.IO;

public class EntryPoint
{
    static void Main( string[] args ) {

        FileStream file = File.OpenRead("test.cs");
        byte[] buffer = new byte[1024];
        
        int c = file.Read(buffer, 0, buffer.Length);

        while (c > 0) 
        {
          Console.WriteLine(System.Text.ASCIIEncoding.ASCII.GetString(buffer));
          c = file.Read(buffer, 0, buffer.Length);
        }

        file.Close();
    }
}

           
         
     


This entry was posted in File Stream. Bookmark the permalink.