I add my test.bat
as a resource via resx. I then try
proc.StartInfo.FileName = myNamespace.Properties.Resources.test;
but it says
System.ComponentModel.Win32Exception: The system cannot find the file specified.'
How can I fix this?
Here is my full code:
public async void button_A_Click(object sender, EventArgs e)
{
button_A.Enabled = false;
await Task.Run(() => {
var proc = new Process();
proc.StartInfo.FileName = LOS_Installer.Properties.Resources.test;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.Arguments = path;
if (proc.Start())
{
void outputCallback(string data)
{
textBoxLog.AppendText(data);
textBoxLog.AppendText(Environment.NewLine);
}
proc.OutputDataReceived += (_, e) => Invoke(outputCallback, e.Data);
proc.ErrorDataReceived += (_, e) => Invoke(outputCallback, e.Data);
proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
}
proc.WaitForExit();
});
button_A.Enabled = true;
}
Minor question: it seems that the resource manager doesn't care about file's extension. So what if I have 2 files with the same name yet different extensions?