A CMD script was created through StreamWriter
. I then used the Process.start()
method to run the CMD script.
In business logic, you invoke methods through infinite loops to create and execute scripts.
Because we have a task that needs to be checked constantly, we used a while loop.
However, an error has occurred:
"0x00000000 referenced memory, memory can not be read."
I searched through Google, but I do not know why this happens.
Problem code...
public void PrintPDFTest()
{
string PRINT_NAME = CGlobalValueables.Instance.PropPrintName;
const string PRINT_PDF = "PrintPDF.cmd";
if (IsCheckSelectFile() == false)
return;
string filePDFProgramPath = _selectFile[1].ToString();
File.Create("PrintPDF.cmd").Dispose();
using (StreamWriter file = new StreamWriter(PRINT_PDF, false, Encoding.Default))
{
file.WriteLine("c:");
file.WriteLine(@"cd C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader");
file.WriteLine(string.Format("AcroRd32.exe /t \"{0}\" \"{1}\" \"\" \"\"", filePDFProgramPath, PRINT_NAME));
}
ProcessStartInfo startInfo = new ProcessStartInfo
{
CreateNoWindow = true,
RedirectStandardError = true,
UseShellExecute = false,
FileName = PRINT_PDF,
WindowStyle = ProcessWindowStyle.Hidden
};
Process.Start(startInfo); // error
}
User contributions licensed under CC BY-SA 3.0