Suppose there is a project with a complex hierarchy.

Is it possible to get the source code of the entire project in VISUAL STUDIO without clicking on all the files in the project?

  • Where to get? In one window? - Vladimir Martyanov
  • Suppose in one window or in a file, from where it can then be easily added to the diploma) - iluxa1810
  • 2
    @ iluxa1810 Well, how can I tell you ... the thing is that Visual Studio was not designed to “add code to the diploma with ease”. And in the production-development of such needs does not arise - DreamChild
  • The copy command can also merge files. - Vladimir Martyanov
  • one
    You do not program, and the diploma must contain a program. I see only one way out: you hire a performer. It will be all the same to you whether it is easy for him to insert his source texts into your diploma. - artoodetoo

1 answer 1

Try to do this:

string rootPath = @"path you your root folder"; var header = "***********************************" + Environment.NewLine; var files = Directory.GetFiles(rootPath, "*.cs", SearchOption.AllDirectories); var result = files.Select(path => new { Name = Path.GetFileName(path), Contents = File.ReadAllText(path)}) .Select(info => header + "Filename: " + info.Name + Environment.NewLine + header + info.Contents); var singleStr = string.Join(Environment.NewLine, result); Console.WriteLine ( singleStr ); File.WriteAllText(@"C:\output.txt", singleStr, Encoding.UTF8); 

Once helped. Found it here: https://stackoverflow.com/questions/15546733/how-to-export-all-the-source-code-from-visual-studio-into-a-text-file