Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/csharp
- using System;
- using System.IO;
- using R7.Scripting;
- class Combine
- {
- public void Run ()
- {
- Directory.SetCurrentDirectory("/home/redhound/Рабочий стол/Регистрация СДК/код/R7.HelpDesk/R7.HelpDesk");
- var log = new Log("combine.log");
- try
- {
- // provided by git ls-files
- var files = File.ReadAllLines ("ls-files.txt");
- var outfile = "single-file.txt";
- var excludeExt = new [] { ".txt", ".md", ".png", ".jpg", ".gif", ".resx" };
- var f = new FileStream (outfile, FileMode.Create, FileAccess.Write, FileShare.None);
- var sw = new StreamWriter (f);
- sw.AutoFlush = true;
- foreach (string file in files)
- {
- var exclude = false;
- var fileExt = Path.GetExtension(file).ToLowerInvariant ();
- foreach (var ext in excludeExt)
- if (fileExt == ext)
- {
- exclude = true;
- break;
- }
- if (exclude) continue;
- try
- {
- sw.WriteLine ();
- sw.WriteLine ("Содержимое файла " + file + ":");
- sw.WriteLine ();
- var lines = File.ReadAllLines (file);
- foreach (var line in lines)
- sw.WriteLine (line);
- Console.WriteLine (file);
- }
- catch (Exception ex)
- {
- log.WriteLine ("Error: " + ex.Message);
- }
- }
- sw.Close();
- f.Close();
- }
- catch (Exception ex)
- {
- log.WriteLine ("Error: " + ex.Message);
- }
- log.Close();
- }
- }
- new Combine().Run ();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement