当前位置:网站首页>[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;
}
边栏推荐
- Redis and database data consistency
- [uniapp] the uniapp mobile terminal uses uni Troubleshooting of navigateback failure
- [recommendation system learning] recommendation system architecture
- 【万字总结】以终为始,详细分析高考志愿该怎么填
- Concurrent thread safety
- How about opening an account at Guojin securities? Is it safe?
- [buuctf.reverse] 126-130
- Treasure and niche CTA animation material website sharing
- No manual prior is required! HKU & Tongji & lunarai & Kuangshi proposed self supervised visual representation learning based on semantic grouping, which significantly improved the tasks of target dete
- 行锁与隔离级别案例分析
猜你喜欢
The difference between round and truncate in SQL (round or truncate)
[code Capriccio - dynamic planning] t583. Deleting two strings
Leetcode - 226. Retourner l'arbre binaire (bfs)
Here comes the hero League full skin Downloader
Treasure and niche CTA animation material website sharing
How pycharm modifies multiline annotation shortcuts
RSA加密解密详解
halcon之区域:多种区域(Region)特征(5)
Synchronized description of concurrency
Vscode usage - Remote SSH configuration description
随机推荐
Leetcode topic [array] -268- missing numbers
Preparing for the Blue Bridge Cup and ccf-csp
力扣每日一题-第28天-566.重塑矩阵
Regular match same character
The king of Internet of things protocol: mqtt
#25class的类继承
JS cast
Static registration and dynamic registration of JNI
map和filter方法对于稀缺数组的处理
Applet setting button sharing function
VSCode使用 - Remote-SSH 配置说明
14 MySQL tutorial insert insert data
腾讯钱智明:信息流业务中的预训练方法探索与应用实践
【Unity】在Unity中使用C#执行外部文件,如.exe或者.bat
ZCMU--1367: Data Structure
[dynamic planning] Jianzhi offer II 091 Paint the house
解决pycharm里面每个字母占一格空格的问题
idea中文插件chinese(simplified) language pack
Let torch cuda. is_ Experience of available() changing from false to true
丰富专业化产品线, 江铃福特领睿·极境版上市