c#二进制文件转文本文件

将二进制文件读取进来,并以16进制显示在txt文档中,这个可以实现。
但是如何同时读取多个dat文件,显示在一个TXT文档里呢,一个dat文件显示成一行的那种。
这是写好的代码。
using System;
using System.ComponentModel;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace BinaryFileReader
{
public partial class Form1 : Form
{
private readonly OpenFileDialog chooseOpenFileDialog = new OpenFileDialog(); //文件对话框
private string chosenFile; //当前文件路径

   //处理菜单和文件对话框的程序
    public Form1()
    {
        InitializeComponent();

        menuFileOpen.Click += OnFileOpen; 
            
        chooseOpenFileDialog.FileOk +=OnOpenFileDialogOK;
    }

    private void OnFileOpen(object Sender, EventArgs e)
    {
        chooseOpenFileDialog.ShowDialog();
    }

    private void OnOpenFileDialogOK(object Sender, CancelEventArgs e)
    {
        chosenFile = chooseOpenFileDialog.FileName;
        Text = Path.GetFileName(chosenFile);//从其获取文件名和扩展名的路径字符串。 
        DisplayFile();
    }
    //读取选中的文件并显示;
    private void DisplayFile()
    {
        int nCols = 16;
        FileStream inStream = new FileStream(chosenFile, FileMode.Open,FileAccess.Read);//实例化FileStream
        long nBytesToRead = inStream.Length;  //确定文件有多少个字节;
       
        int nLines = (int)(nBytesToRead / nCols) ;//计算总共显示多少行;
        string[] lines = new string[nLines];
        int nBytesRead = 0;//读取的字节数
        for (int i = 0; i < nLines; i++)
        {
            StringBuilder nextLine = new StringBuilder();//构造每一文本行
            //nextLine.Capacity = 4 * nCols;
            for (int j = 0; j < nCols; j++)
            {
                int nextByte = inStream.ReadByte();
                nBytesRead++;
               
                char nextChar = (char)nextByte;//强制转换为字符
               
                if (nextChar < 16)  //值小于16的字符的显示方法
                    nextLine.Append(" 0" + string.Format("{0,1:X}", (int)nextChar));
               
                else
                    nextLine.Append(" "+string.Format("{0,2:X}", (int)nextChar));
                                                        
            }
            lines[i] = nextLine.ToString();
        }
        inStream.Close();
        //textBoxContents.Lines = lines;
        richTextBox1.Lines = lines;
    }

    private void button1_Click(object sender, EventArgs e)
   { 

        //将读进来的文件保存成txt格式
        if (this.richTextBox1.Text == "")
                return;
            saveFileDialog1.DefaultExt = "txt";
            saveFileDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
           if (this.saveFileDialog1.ShowDialog() == DialogResult.Cancel)
               return;
            string FileName = this.saveFileDialog1.FileName;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK && FileName.Length > 0)
            {
                // Save the contents of the RichTextBox into the file.
                richTextBox1.SaveFile(FileName, RichTextBoxStreamType.PlainText);
                MessageBox.Show("文件已成功保存");
            }
      
    }

    
}

}

var ar = 文件列表.Select(fn=>
BitConverter.ToString(File.ReadAllBytes(fn)).Replace('-', ' ')).ToArray();
File.WriteAllLines("文件名",ar);