using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp;
string pathToDll = "path_to_your_dll_file.dll";
string outputPath = "path_to_output_text_file.txt";
var decompiler = new CSharpDecompiler(pathToDll, new DecompilerSettings());
var syntaxTree = decompiler.DecompileWholeModuleAsSingleFile();
string decompiledCode = syntaxTree.ToString();
File.WriteAllText(outputPath, decompiledCode);