厭倦了等待,這就是我想出了:
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;
}
}
}
如果你的學校要求這個,肯定有人已經解決了所有的解決方案的代碼文件轉換成PDF格式的問題? –
http://superuser.com/questions/389318/looking-for-software-that-will-batch-convert-a-folder-tree-containing-chm-files –
米奇,這就是我的想法,爲什麼我在這裏。因爲我相信這一點,所以必須有一個工具。學校也沒有給我們任何工具。 –