Created
January 28, 2018 20:58
-
-
Save JakubNei/2b108a9a99d8413969e6478c0e9dc904 to your computer and use it in GitHub Desktop.
Slightly improved version of https://gist.github.com/Traderain/de87d093a2ce72010efe32cdc590a4ab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Windows.Forms; | |
namespace wcclitedumper | |
{ | |
class Program | |
{ | |
[STAThread] | |
static void Main(string[] args) | |
{ | |
Console.Title = "wcc_lite CR2W Dumper"; | |
string wccpath; | |
using (var f1 = new OpenFileDialog() | |
{ | |
CheckPathExists = true, | |
Title = "Select wcc_lite.exe", | |
FileName = "wcc_lite.exe", | |
}) | |
{ | |
if (f1.ShowDialog() == DialogResult.OK) | |
wccpath = f1.FileName; | |
else | |
return; | |
} | |
string dumpfolder; | |
using (var f2 = new FolderBrowserDialog() | |
{ | |
Description = "Select Temporary Dumping Folder", | |
ShowNewFolderButton = true, | |
}) | |
{ | |
if (f2.ShowDialog() == DialogResult.OK) | |
dumpfolder = f2.SelectedPath; | |
else | |
return; | |
} | |
string resultfolder; | |
using (var f3 = new FolderBrowserDialog() | |
{ | |
Description = "Select Result Folder", | |
ShowNewFolderButton = true, | |
}) | |
{ | |
if (f3.ShowDialog() == DialogResult.OK) | |
resultfolder = f3.SelectedPath; | |
else | |
return; | |
} | |
using (var of = new FolderBrowserDialog() | |
{ | |
Description = "Select Source Folder" | |
}) | |
//using (var of = new OpenFileDialog()) | |
{ | |
if (of.ShowDialog() == DialogResult.OK) | |
{ | |
Console.WriteLine("Dumping files:"); | |
foreach (var file in Directory.GetFiles(of.SelectedPath, "*.*", SearchOption.AllDirectories)) | |
{ | |
Console.WriteLine("\t" + file); | |
} | |
Console.WriteLine(); | |
//of.Multiselect = true; | |
foreach (var file in Directory.GetFiles(of.SelectedPath, "*.*", SearchOption.AllDirectories)) | |
{ | |
Directory.CreateDirectory(dumpfolder); | |
Directory.CreateDirectory(resultfolder); | |
foreach (var s in Directory.GetFiles(dumpfolder, "*.*")) | |
{ | |
File.Delete(s); | |
} | |
var workingpath = Path.Combine(dumpfolder, Path.GetFileName(file)); | |
File.Copy(file, Path.Combine(dumpfolder, Path.GetFileName(file))); | |
Console.WriteLine(); | |
Console.WriteLine(); | |
Console.WriteLine("-- Dumping: " + file); | |
var proc = new Process(); | |
Directory.CreateDirectory(dumpfolder); | |
proc.StartInfo = new ProcessStartInfo(wccpath, BuildCommand(workingpath, resultfolder)); | |
Console.WriteLine("\tArguments: " + proc.StartInfo.Arguments); | |
Console.WriteLine(); | |
Console.WriteLine("---------<wcc_lite log>--------------"); | |
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(wccpath); | |
proc.StartInfo.CreateNoWindow = true; | |
proc.StartInfo.UseShellExecute = false; | |
proc.StartInfo.RedirectStandardOutput = true; | |
proc.StartInfo.RedirectStandardError = true; | |
proc.Start(); | |
proc.BeginOutputReadLine(); | |
proc.BeginErrorReadLine(); | |
proc.ErrorDataReceived += Recieved; | |
proc.OutputDataReceived += Recieved; | |
proc.WaitForExit(); | |
Console.WriteLine("---------</wcc_lite log>-------------"); | |
foreach (var s in Directory.GetFiles(dumpfolder, " *.xml")) | |
{ | |
Console.WriteLine("File moved to desktop dump dir!"); | |
File.Move(s, Path.Combine(resultfolder, Path.GetFileName(s))); | |
} | |
} | |
} | |
} | |
Console.WriteLine("Done!"); | |
Console.ReadLine(); | |
} | |
public static void Recieved(object sender, DataReceivedEventArgs rec) | |
{ | |
if (rec?.Data != null) | |
Console.WriteLine(rec.Data); | |
} | |
public static string BuildCommand(string infile, string outfile) | |
{ | |
return $"dumpfile -file={infile} -out={outfile}"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment