当前位置:网站首页>[unity] use C in unity to execute external files, such as Exe or bat
[unity] use C in unity to execute external files, such as Exe or bat
2022-06-26 17:59:00 【T.D.C】
Sample code
var process = ExecuteFile(workPath, exePath);
if (process.Start())
{
Debug.Log(ReadToEnd(process.StandardOutput));
}
Debug.LogError(ReadToEnd(process.StandardError));
Tool code
public static string ReadToEnd(StreamReader reader)
{
var sbd = new StringBuilder();
while (true)
{
var readLine = reader.ReadLine();
if (readLine == null)
{
break;
}
sbd.AppendLine(readLine);
}
return sbd.ToString();
}
public static Process ExecuteFile(string workDir, string executeFile)
{
var process = new Process();
var startInfo = new ProcessStartInfo(executeFile)
{
WorkingDirectory = workDir,
CreateNoWindow = false,
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
RedirectStandardError = true,
StandardOutputEncoding = Encoding.GetEncoding("GB2312"),
StandardErrorEncoding = Encoding.GetEncoding("GB2312"),
};
process.StartInfo = startInfo;
return process;
}
边栏推荐
- 【代码随想录-动态规划】T583、两个字符串的删除操作
- Halcon's region: features of multiple regions (5)
- 清华&商汤&上海AI&CUHK提出Siamese Image Modeling,兼具linear probing和密集预测性能!
- I want to know. I am in Zhaoqing. Where can I open an account? Is it safe to open an account online?
- Concurrent thread safety
- Various types of gypsum PBR multi-channel mapping materials, please collect them quickly!
- 数据加密标准(DES)概念及工作原理
- 并发之线程安全
- LeetCode——226. 翻转二叉树(BFS)
- 非对称密码体制详解
猜你喜欢

Strength and appearance Coexist -- an exclusive interview with Liu Yu, a member of Apache pulsar PMC

数字签名标准(DSS)

VSCode使用 - Remote-SSH 配置说明

#25class的类继承

二分查找-2

Lm06 the mystery of constructing the bottom and top trading strategy only by trading volume

next(iter(dataloader))的一点点体会

Analysis of deep security definition and encryption technology
![[ten thousand words summary] starting from the end, analyze in detail how to fill in the college entrance examination volunteers](/img/77/715454c8203d722e246ed70e1fe0d8.png)
[ten thousand words summary] starting from the end, analyze in detail how to fill in the college entrance examination volunteers

Padding percentage operation
随机推荐
Connected to surface test questions
Let torch cuda. is_ Experience of available() changing from false to true
Prometeus 2.34.0 新特性
Please advise tonghuashun which securities firm to choose for opening an account? Is it safe to open an account online now?
Prometeus 2.34.0 new features
并发之线程安全
临时关闭MySQL缓存
【代码随想录-动态规划】T583、两个字符串的删除操作
Binary search-1
DoS及攻击方法详解
Use FST JSON to automatically generate faster JSON serialization methods
How to open a stock account? Is it safe to open an account online now?
Case study of row lock and isolation level
transforms. The input of randomcrop() can only be PIL image, not tensor
How does Guosen Securities open an account? Is it safe to open a stock account through the link
Decision tree and random forest
The king of Internet of things protocol: mqtt
[ten thousand words summary] starting from the end, analyze in detail how to fill in the college entrance examination volunteers
RSA concept explanation and tool recommendation - LMN
数字签名标准(DSS)