当前位置:网站首页>[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;
}
边栏推荐
- properties文件乱码
- Detailed explanation of asymmetric cryptosystem
- Chen Qiang: Alibaba's 100 billion level large-scale digital business knowledge map helps business growth
- vue--vuerouter缓存路由组件
- [ten thousand words summary] starting from the end, analyze in detail how to fill in the college entrance examination volunteers
- 让torch.cuda.is_available()从false变成true的一点经验
- 深入理解MySQL锁与事务隔离级别
- A little experience of next (ITER (dataloader))
- 陈强:阿里千亿级大规模数字商业知识图谱助力业务增长
- [recommendation system learning] recommendation system architecture
猜你喜欢

RSA encryption and decryption details

【uniapp】uniapp手机端使用uni.navigateBack失效问题解决

决策树与随机森林

DoS及攻击方法详解

Tsinghua & Shangtang & Shanghai AI & CUHK proposed Siamese image modeling, which has both linear probing and intensive prediction performance!

数字签名论述及生成与优点分析

9、智慧交通项目(2)

一起备战蓝桥杯与CCF-CSP之大模拟炉石传说

RSA概念详解及工具推荐大全 - lmn

Synchronized description of concurrency
随机推荐
How about opening an account at Guojin securities? Is it safe?
Row lock analysis and deadlock
数据加密标准DES安全性
二分查找-2
Troubleshooting ideas that can solve 80% of faults!
RSA concept explanation and tool recommendation - LMN
Rich professional product lines, and Jiangling Ford Lingrui · Jijing version is listed
Bayesian network explanation
in和exsits、count(*)查询优化
properties文件乱码
我想知道,我在肇庆,到哪里开户比较好?网上开户是否安全么?
Runtimeerror: CUDA error: out of memory own solution (it is estimated that it is not applicable to most people in special circumstances)
用redis做用户访问数据统计HyperLogLog及Bitmap高级数据类型
vutils. make_ A little experience of grid () in relation to black and white images
牛客网:设计LRU缓存结构 设计LFU缓存结构
Lm06 the mystery of constructing the bottom and top trading strategy only by trading volume
halcon之区域:多种区域(Region)特征(5)
决策树与随机森林
【Unity】在Unity中使用C#执行外部文件,如.exe或者.bat
你好,现在网上股票开户买股票安全吗?