I'm creating an app that copy files to android device. When I run via cmd or powershell, it shows a percentage of copied files, but when using the following code, those not redirect the output. I try to create a CMD process, an ADB process, powershell, nothing, only shows the output at the end of the precess.
folderToLoad = txtOBBFolder.Text;
process = new Process();
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + @"\adb.exe";
process.StartInfo.Arguments = @"push " + folderToLoad + " /sdcard/Android/obb/" + Path.GetFileName(folderToLoad);
process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = false;
process.Start();
q = "";
while (!process.HasExited)
{
q += process.StandardOutput.ReadToEnd();
q += process.StandardError.ReadToEnd();
txtOutput.AppendText(q);
}
Any one as a better way to make this?
If the adb push takes a while, for the user, it seems that the program hang up, thats why I would like to show a progress bar for example, with the percentage that is being sent.