C# Beginner to advanced – Lesson 60 – Stream reader and stream writer (System.IO)

18
12



Stream reader and stream writer:
C# includes following standard IO (Input/Output) classes to read/write from different sources like a file, memory, network, isolated storage, etc.
Stream: 
System.IO.Stream is an abstract class that provides standard methods to transfer bytes (read, write, etc.) to the source.
Classes that need to read/write bytes from a particular source must implement the Stream class.
The following classes inherits Stream class to provide functionality to Read/Write bytes from a particular source:
FileStream: reads or writes bytes from/to a physical file whether it is a .txt, .exe, .jpg or any other file. FileStream is derived from the Stream class.
MemoryStream: MemoryStream reads or writes bytes that are stored in memory.
BufferedStream: BufferedStream reads or writes bytes from other Streams to improve the performance of certain I/O operations.
NetworkStream: NetworkStream reads or writes bytes from a network socket.
PipeStream: PipeStream reads or writes bytes from different processes.
CryptoStream: CryptoStream is for linking data streams to cryptographic transformations.

Readers and Writers:
StreamReader: StreamReader is a helper class for reading characters from a Stream by converting bytes into characters using an encoded value. It can be used to read strings (characters) from different Streams like FileStream, MemoryStream, etc.
StreamWriter: StreamWriter is a helper class for writing a string to a Stream by converting characters into bytes. It can be used to write strings to different Streams such as FileStream, MemoryStream, etc.
BinaryReader: BinaryReader is a helper class for reading primitive datatype from bytes.
BinaryWriter: BinaryWriter writes primitive types in binary.

ankpro
ankpro training
Asp.net MVC
C#
C sharp
Bangalore
Rajajinagar
Selenium
Coded UI
Mobile automation testing
Mobile testing
JQuery
JavaScript
.Net
Components of the .Net framework
Hello World
Literal
Keywords
Variable
Data types
Operators
Branching
Loops
Arrays
ArrayList
Strings
String Builder
Structures
Enums
Functions
Classes
Inheritance
Polymorphism
Properties
Indexers
Events
Nested Classes
Delegates
Anonymous methods
Labda expressions
Abstract classes
Exception Handling
Linq
Interfaces
Extension methods
Anonymous types
Generics
Collections
Garbage Collection
Reflection
Attributes
Input and output statements
Type casting
Partial Methods
Partial Classes
Boxing and Unboxing
Var vs Dynamic vs Object
using Static.
Auto property initializer.
Dictionary Initializer.
nameof Expression.
New way for Exception filters.
await in catch and finally block.
Null – Conditional Operator.
Expression – Bodied Methods
Easily format strings – String interpolation
Parameterless constructors in structs.
Creating a custom exceptions class.

Nguồn:https://wijstaanvooronzegrondrechten.org/

18 COMMENTS

  1. Please fix your audio levels, one moment you are shouting the next you are too quiet, try to balance this with some software, other than that, tutorial was great

  2. Very good content but You should speak slowly and some of your speech is not clear. Those were very hard to catch what you are trying to say. I was feeling like I'm hearing a memorized essay from a student. Except that everything was good.

  3. Very good tutorial -just because English is not your first language slow down a notch (to better capture audience not accustomed to ESL speakers) thanks again!

  4. here is my code
    namespace AuploadFlowers.classes
    {
    public class FilesHelper
    {
    public static string UploadPhoto(HttpPostedFileBase file, string folder)
    {
    var path = string.Empty;
    var pic = string.Empty;
    if (file != null)
    {
    pic = Path.GetFileName(file.FileName);
    path = Path.Combine(HttpContext.Current.Server.MapPath(folder) , pic);
    file.SaveAs(path);
    using (MemoryStream ms = new MemoryStream())
    {
    file.InputStream.CopyTo(ms);
    byte[] array = ms.GetBuffer();
    }
    }
    return pic;
    }
    }
    Can you explain memory stream?

  5. Hello, great video, I have follwing problem I thought I could solve it with your vid, maybe you can help me?

    I want to write into an external console, means I have an console which is connected to an arduino and now I want to write something into this console by clicking on a button in my wpf (c#) application. Is there a possibility to do this? It is for a school
    project and no one of my teachers knows how to do this ;)) Thanks in advance

LEAVE A REPLY

Please enter your comment!
Please enter your name here