Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2021
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5.  
  6. namespace ExtractBytes
  7. {
  8.     public class ExtractBytes
  9.     {
  10.         public static void ExtractBytesFromBinaryFile(string binaryFilePath, string bytesFilePath, string outputPath)
  11.         {
  12.             using StreamReader streamReader = new StreamReader(bytesFilePath);
  13.             byte[] fileBytes = File.ReadAllBytes(binaryFilePath);
  14.             var bytesList = new List<String>();
  15.             var sb = new StringBuilder();
  16.  
  17.             while (!streamReader.EndOfStream)
  18.             {
  19.                 bytesList.Add(streamReader.ReadLine());
  20.             }
  21.             foreach (var item in fileBytes)
  22.             {
  23.                 if (bytesList.Contains(item.ToString()))
  24.                 {
  25.                     sb.AppendLine(item.ToString());
  26.                 }
  27.                
  28.             }
  29.             using StreamWriter file = new System.IO.StreamWriter(outputPath);
  30.             file.WriteLine(sb.ToString().Trim());
  31.         }
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement