- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我试图理解为什么当我调用上述函数时,我在读取的输出中每第 80 列得到十六进制 0D0A。
我有一个 powershell 脚本,为了简洁起见,其中有两行用于测试:
$xmlSpew = "<IISAppPoolConfig><DefaultWebSite><ApplicationPoolName>DefaultAppPool</ApplicationPoolName></DefaultWebSite><AuthN>Basic</AuthN></IISAppPoolConfig>"
Write-Output $xmlSpew
我正在使用带有 ProcessStartInfo 的 Process 对象调用脚本,如下所示:
var psi = new ProcessStartInfo
{
WorkingDirectory = Path.GetDirectoryName(FileToRun),
FileName = FileToRun,
Arguments = Arguments,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardOutput = true,
};
var process = new Process
{
StartInfo = psi,
EnableRaisingEvents = true,
};
FileToRun 值为:
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
参数值为:
-File "C:\Program Files\MyTest\MyProgInputs\read.d\IISAppPoolConfig.ps1"
脚本运行良好,我返回退出代码 0,但我在标准输出中每 80 个字符就有一个神秘的(对我来说)0D0A 换行符,我使用以下方法捕获:
var Stdout = new List<string>;
...
Stdout.Add(process.StandardOutput.ReadToEnd());
一旦我将标准输出存储在字符串 var 中,这就会对我的 XML 工作造成严重破坏。我希望得到我在 ps1 脚本中写入标准输出的确切内容,而不是额外的换行符。
我错过了什么?我找过其他有这个问题的人,但我没有找到答案。希望不是我受到搜索挑战。
最佳答案
关注this P/Invoke 方法并将 dwXCountChars
设置为一个非常大的值。不要忘记在标志中也包含 STARTF_USECOUNTCHARS
。
关于c# - Process.StandardOutput.ReadToEnd() 和无关的换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11295922/
我正在研究 C++/CLI winforms 如何将标准输出重定向到文本框? 我关注了这个视频,但没有成功 https://www.youtube.com/watch?v=BDTCviA-5M8 我可
我正在尝试使用 C# 来控制命令行应用程序后台,可以在这里下载:http://www.ti.com/litv/zip/spmc015b 这是一个电机电压控制的应用程序,当我进入应用程序时,如“b.ex
我正在尝试做一些似乎超出 System.Diagnostics.Process 对象范围的事情。可接受的答案可以提出不同的方法,只要它使用 .net 4.5/c#5。 我的程序正在调用 gdalwar
我有一个使用 BeginOutputReadLine 以异步模式启动命令行进程的程序。我的问题是 .Exited 事件在仍有一些 .OutputDataReceived 事件被触发时被触发。我在 .E
我正在用类似于下面的代码开始一个过程: // some of the flags are not needed process.StartInfo.CreateNoWindow = true; pro
我使用 C# 处理进程(使用 Process 和 ProcessStartInfo)已经有一段时间了。现在只有一个问题一直困扰着我,一直没有找到解决的办法。 当应用程序“等待”某些输入时,Standa
我正在我的 C# 应用程序中启动一个进程,该进程运行一个控制台应用程序。我已经重定向了标准输入和输出,并且能够通过 StandardOutput.ReadLine() 读取几行。我确信我已正确配置 P
这个问题在这里已经有了答案: ProcessStartInfo hanging on "WaitForExit"? Why? (22 个答案) 关闭 5 年前。 我有一个经常使用外部程序并读取其输出
我有这个小函数,可以让我在处理可怕的 System.Diagnostics.Process API 时省去一些麻烦: let HiddenExec (command: string, argument
我正在尝试获取输出以显示我机器上当前打开的文档,但无论如何它都返回 NULL。 StringCollection values = new StringCollection(); var proc =
在 this 之上问题,我还有一个。我尝试从外部进程获取二进制数据,但数据(图像)似乎已损坏。下面的屏幕截图显示了损坏:左图是通过在命令行上执行程序完成的,右图是通过代码完成的。 到目前为止我的代码:
在 C# 中(.NET 4.0 在 SuSE 上的 Mono 2.8 下运行)我想运行一个外部批处理命令并以二进制形式捕获它的输出。我使用的外部工具称为“samtools”(samtools.sour
我正在读取使用 Process 启动的 java 应用程序的输出,并读取 stdError、stdOutout 并使用 stdInput 发送命令。相关代码如下: int mem =
我正在尝试从 C# 运行命令行实用程序 PCLI.exe,但没有成功。我正在构建一个 ProcessStartInfo 对象并设置了 process.StartInfo.RedirectStandar
我试图理解为什么当我调用上述函数时,我在读取的输出中每第 80 列得到十六进制 0D0A。 我有一个 powershell 脚本,为了简洁起见,其中有两行用于测试: $xmlSpew = "Defau
我正在启动一个控制台应用程序,但是当我重定向标准输出时,我总是什么也得不到! 当我不重定向它,并将 CreateNoWindow 设置为 false 时,我在控制台中正确地看到了所有内容,但是当我重定
我read这部分代码可能会导致死锁: Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.Re
这个问题以前不止一次被问过,但我在这些讨论中都没有找到满意的答案。 我正在启动一个命令行进程,为 STDOUT 生成实时测量值,大约每秒生成一个新结果。使用 System.Diagnostics.Pr
在 C# 中(.NET 4.0 在 SuSE 上的 Mono 2.8 下运行)我想运行一个外部批处理命令并以二进制形式捕获它的输出。我使用的外部工具称为“samtools”(samtools.sour
是否可以在 Gradle 中的 JavaExec 命令上将 java 命令添加到标准输出流? 即 task importSitesDef(dependsOn: init, type: JavaExec
我是一名优秀的程序员,十分优秀!