C#C
C#2y ago
Haxo

How to Read byte by byte until EOF?

Hello! I couldn't find an answer on the internet on this question so I guess I will have to ask it.
I am trying to make my own version of WinRar and to avoid using too much RAM I want to read and write the file byte by byte. How do I do it?

Here's the code:
using System;
using System.IO;

namespace Paxer;

class Core
{
    public static void writeFile(FileStream _target, string root, string sub_path)
    {
        // What is origin?
        string full_path = Path.Combine(root, sub_path);

        FileInfo file_info = new FileInfo(full_path);
        FileStream _from = new FileStream(full_path, FileMode.Open);

        // Lenghts
        long path_len = sub_path.Length;
        byte[] path_blen = BitConverter.GetBytes(path_len);

        long len = file_info.Length;
        byte[] blen = BitConverter.GetBytes(len);

        // Write
        byte b;
        
        // What to do here ???
    }
}
Was this page helpful?