Skip to content

Instantly share code, notes, and snippets.

@JakubNei
Last active January 28, 2018 21:02
Show Gist options
  • Save JakubNei/484a5f096549006646ff3c4b1844f414 to your computer and use it in GitHub Desktop.
Save JakubNei/484a5f096549006646ff3c4b1844f414 to your computer and use it in GitHub Desktop.
Added file/folder select windows so my friend can use it without the need to compile it manually, original source: https://gist.github.com/Traderain/de87d093a2ce72010efe32cdc590a4ab Compiled exe download: https://www.dropbox.com/s/x9dyogf9cj0pes3/wcc_lite_dumper.exe
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