Turn the solution to a pdf or doc file

This may seem like a strange question, but I need to turn my code into a pdf file, so I can transfer it. Yes, unfortunately, the school system requires code on a CD in pdf format. I could open every class in my solution and copy it. But - as a programmer - I'm lazy and would like to know if Visual Studio has any features for this? or if there is another way?

Edit: A third-party program that iterates through all the files in a folder, opens the file and copies its contents to a PDF file. Would also - it should not be in Visual Studio.

+4
source share
1 answer

Tired of waiting, this is what I came up with:

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace GetFileContents { class Program { static string types = ".js,.cshtml,.cs,.less,.css"; private static string text = ""; static void Main(string[] args) { //This folder wraps the whole thing. string folderPath = @"C:\randomFolderWhereProjectIs\"; string s = IterateIt(Directory.GetDirectories(folderPath).ToList()); //Save to file or whatever I just used the text visualiser in Visual Studio } private static string IterateIt(List<string> l) { foreach (var path in l) { var files = Directory.GetFiles(path).Select(c => new FileInfo(c)).Where(c => types.Split(',').Contains(c.Extension)); foreach (var fileInfo in files) { text += fileInfo.Name + "\r\n"; using (StreamReader reader = fileInfo.OpenText()) { text += reader.ReadToEnd() + "\r\n"; } } text = IterateIt(Directory.GetDirectories(path).ToList()); } return text; } } } 
+1
source

Source: https://habr.com/ru/post/1415096/


All Articles