I'm trying to load code from an exe file then create it into a new .exe file. But it's not recognizing my variable "SourceCode". It says the name "SourceCode" does not exist in the current context
private void button1_Click(object sender, EventArgs e)
{
using (FileStream SourceCode = new FileStream("thecode.exe", FileMode.Open, FileAccess.ReadWrite, FileShare.None));
string Output = textBox3.Text;
String[] Assembly = { "System.dll", "System.Drawing.dll", "System.Windows.Forms.dll" };
CodeDomProvider CodeCompiler = CodeDomProvider.CreateProvider("CSharp");
CompilerParameters Parameters = new CompilerParameters(Assembly, "");
Parameters.OutputAssembly = Output;
Parameters.GenerateExecutable = true;
Parameters.GenerateInMemory = false;
Parameters.WarningLevel = 3;
Parameters.TreatWarningsAsErrors = true;
Parameters.CompilerOptions = "/optimize+ /target:winexe";
string Errors = null;
try
{
CompilerResults Results = null;
Results = CodeCompiler.CompileAssemblyFromSource(Parameters, SourceCode); //This here is giving me an error
if (Results.Errors.Count > 0)
{
Errors = "";
foreach (System.CodeDom.Compiler.CompilerError CompileError in Results.Errors)
{
Errors += "Line number " + CompileError.Line + ", Error Number: " + CompileError.ErrorNumber + ", '" + CompileError.ErrorText + ";\r\n\r\n";
}