void BuildProjects()
{
String outputPath = @"D:\PIT\ProcessImprovementTool\DLL";
console = new Process();
console.StartInfo.FileName = "cmd.exe";
console.StartInfo.UseShellExecute = false;
console.StartInfo.CreateNoWindow = true;
console.StartInfo.RedirectStandardInput = true;
console.StartInfo.RedirectStandardOutput = true;
console.StartInfo.RedirectStandardError = true;
console.Exited += new EventHandler((sender, e) =>
{
Console.WriteLine("if (console.Exited) --> ExitCode: " + console.ExitCode);
BuildProjects();
});
console.OutputDataReceived += new DataReceivedEventHandler(ConsoleOutputHandler);
console.ErrorDataReceived += new DataReceivedEventHandler(ConsoleOutputHandler);
console.Start();
using (StreamWriter sw = console.StandardInput)
{
sw.AutoFlush = true;
console.StandardInput.AutoFlush = true;
if (sw.BaseStream.CanWrite)
{
sw.WriteLine("D:\\PIT\\ProcessImprovementTool\\callVcvars32.bat");
sw.WriteLine("cls");
for (int ctr = 0; ctr < 5; ctr++)
{
sw.WriteLine("msbuild /property:OutputPath=" + outputPath + @";OutputType=Library " + lines[ctr]);
//console.BeginOutputReadLine();
sw.Flush();
}
}
if (tryout)
{
Console.WriteLine("working");
}
sw.Close();
//sw.Flush();
}
console.BeginOutputReadLine();
console.BeginErrorReadLine();
//console.WaitForExit();
counter++;
}
imWie lösche ich vorherige Zeilen von StreamWriter?
for (int ctr = 0; ctr < 5; ctr++)
{
sw.WriteLine("msbuild /property:OutputPath=" + outputPath + @";OutputType=Library " + lines[ctr]);
//console.BeginOutputReadLine();
sw.Flush();
}
wenn ich die Grenze für ctr auf 40 gesetzt (ctr < 40) meine Anwendung hängt .. und ich bekommen, dass der Strom bereits am Limit ist ..
basierend auf meiner Forschung - .Flush() sollte den Trick machen. oder AutoFlush auf True setzen. aber scheint nicht zu funktionieren.
so wie kann ich klar vorherige Stream Aufzeichnungen .. oder etwas, das mir lassen würde Eingabe mehr als 40 Zeilen? .. (ich erhalte mehr als 100, aber nicht mehr als 150 Zeilen in stream schreiben) ..
„Linien“ Variable speichert den Wert von „build.txt“
void readFromBuild()
{
doneReading = true;
lines = System.IO.File.ReadAllLines(@"D:\PIT\ProcessImprovementTool\Build\build.txt");
//System.Console.WriteLine("Contents of WriteLines2.txt = ");
foreach (string line in lines)
{
lineCount++;
}
Console.WriteLine(lineCount);
lineCount = lineCount - limit;
}
„build.txt“ enthält alle Dateien DLL-Dateien kompiliert werden .. Für mich
Was ist das "Linien"? Ich habe es nirgendwo in deinem Code gefunden! –
Möchten Sie alle vorherigen Zeilen löschen? Oder nur letzte Zeile? können Sie versuchen, diese 'mit (StreamWriter sw = neue StreamWriter (fileToClear)) { sw.Write (" "); } ' – HEGDE
uhmm .. es nicht tatsächlich in einer Datei .. krank bearbeiten es Sir – John