/// <summary> /// Starts the obfuscation process. All parameters related to the obfuscation process must be set manually, /// and not through the use of a ObfuscationConfig file. /// </summary> /// <param name="sourceDir">Source code directory</param> /// <param name="targetDir">Target directory for the obfuscated files</param> /// <param name="filesToObfuscate">Files from the source directory that are to be obfuscated</param> /// <param name="async">Flag indicating whether to run this process asynchronously. If true, this function will /// return as soon as the file copy is done. False will result in the function returning only after all obfuscation /// has completed.</param> public void Start(string sourceDir, string targetDir, List <string> filesToObfuscate, bool async) { // if the target directory exists, wipe it out try { if (Directory.Exists(targetDir)) { Directory.Delete(targetDir, true); } } catch (Exception) { _ui.Error("Could not delete target directory: " + targetDir); return; } try { // if the target does not exist, create it. if (!Directory.Exists(targetDir)) { Directory.CreateDirectory(targetDir); } } catch (Exception) { _ui.Error("Could not create target directory: " + targetDir); return; } try { // copy every file recursively from the source to the target directory string[] files = Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories); _targetFiles = new List <string>(files.Length); foreach (string file in files) { string targetFile = file.Replace(sourceDir, targetDir); if (filesToObfuscate.Contains(file)) { _targetFiles.Add(targetFile); } FileInfo info = new FileInfo(targetFile); if (!info.Directory.Exists) { info.Directory.Create(); } _ui.StatusUpdate("Copying file: " + targetFile); File.Copy(file, targetFile); } } catch (Exception) { _ui.Error("Could not copy files from source to target directory"); return; } try { if (async) { Thread obfThread = new Thread(new ThreadStart(ObfThread)); obfThread.Start(); } else { ObfThread(); } } catch (Exception exp) { _ui.Error("There was an error obfuscating: " + exp.Message); return; } }