c# - 如何使用 C# 在 OSX 中正确运行 chmod?
问题描述
我和这里有同样的问题How run chmod in OSX with C#
我想通过我尝试过的 Unity 中的代码更改权限:
ProcessStartInfo startInfo = new ProcessStartInfo()
{
FileName = "chmod",
Arguments = "+x " + "Game.app/Contents/MacOS/Game"
};
Process proc = new Process() { StartInfo = startInfo, };
proc.Start();
但不起作用,有什么建议吗?
解决方案
我不确定,但也许你首先必须打开例如bash
,然后使用类似的东西将chmod
调用作为参数传递-c
ProcessStartInfo startInfo = new ProcessStartInfo()
{
FileName = "/bin/bash",
Arguments = "-c \" chmod +x Game.app/Contents/MacOS/Game\" ",
CreateNoWindow = true
};
Process proc = new Process() { StartInfo = startInfo, };
proc.Start();
仍然假设当然路径是正确的。
并且也许还添加一些回调,例如
proc.ErrorDataReceived += (sender, e) =>
{
UnityEngine.Debug.LogError(e.Data);
};
proc.OutputDataReceived += (sender, e) =>
{
UnityEngine.Debug.Log(e.Data);
};
proc.Exited += (sender, e) =>
{
UnityEngine.Debug.Log(e.ToString());
};
proc.Start();
推荐阅读
- mysql - MySQL binlog_expire_logs_seconds 不工作
- postgresql - 如何解决流命令的错误读取结果?
- typescript - 使用 switch 语句缩小类型不适用于泛型类型
- jenkins - Jenkins 升级后下游作业缺少参数
- raku - 您如何使用 Raku 发出 HTTP 请求?
- swift - 无法使用本地用户体验调用 App Clip
- parsing - 使用powershell脚本解析ETL文件
- c# - 使用通用接口属性实现接口时使用兼容的具体类型
- android - Firebase firestore 查询不会过滤数据,即使在颤振中使用 where
- numpy - 如何找出每行nd数组中特定元素的出现次数?