我的脚本是用python和gui编写的,它是用c编写的。这就是为什么我想从c运行python(由于ironpython不支持各种模块,我不得不使用原始的python版本)。为了保护脚本的安全,我将其嵌入到.exe文件中。现在,我怎样才能得到脚本路径?
我以前的代码:
string python = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\python\python.exe";
// NOW it obviously does not work
string scriptPath = @"C:\..\script.py";
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(python);
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.Arguments = scriptPath;
Process myProcess = new Process();
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
assembly.getExecutingAssembly().getManifestResourceStream(…)
在这里不会有用,因为我不想要stream(或者我想要stream?),就这条路。