Read ASCII string from byte buffer : Text File Read Write « File Stream « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » File Stream » Text File Read WriteScreenshots 
Read ASCII string from byte buffer
Read ASCII string from byte buffer
  

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

public class EntryPoint
{
    static void Mainstring[] 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();
    }
}

           
         
    
  
Related examples in the same category
1.Read and Write a Text File
2.Read text file line by line
3.Reads and displays bytes until end-of-fileReads and displays bytes until end-of-file
4.Write string to a text file
5.Read whole text file to the end
6.Read text file line by line with exception catch
7.Text file Write with format and write boolean value to a text file
8.Action Text Reader Line
9.Open and Append to a Log File
10.Read and Write to a Newly Created Data File
11.Read Text from a File
12.Read text file with File.OpenText
13.Write Text to a File
w_ww___._j__a_v___a_2_s___._c__o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.