如何使用 C# 运行 在 OSX 中正确地进行 chmod?
How to run properly chmod in OSX with C#?
我和这里有同样的问题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
然后使用 -c
作为参数传递 chmod
调用,例如
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();
我和这里有同样的问题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
然后使用 -c
作为参数传递 chmod
调用,例如
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();