在我的c#代码中我有
const options = {
chart: {
type: 'pie',
events: {
load: function() {
const series = this.series[0];
const points = series.data;
const chart = this;
points.forEach(function(point) {
if (point.y <= 4) {
const myOffset = 50;
const {x: centerX, y: centerY} = point.graphic.attr();
const {x, y} = point.dataLabel.attr();
const angle = point.angle;
point.dataLabel.attr({
x: x + Math.cos(angle) * myOffset,
y: y + Math.sin(angle) * myOffset
});
}
});
}
}
},
title: {
text: ''
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
distance: -40,
formatter: function() {
return this.y + '%';
}
},
showInLegend: true
}
},
series: [{
//innerSize: '60%',
data: [{name: 'Staff Delegation', y:77}, {name: 'AAP', y:11}, {name: 'DCC', y:8.5}, {name: 'Council', y:3.5}]
}]
}
const chart = Highcharts.chart('container', options);
在我的do.cmd中我有
processInfo = new ProcessStartInfo("do.cmd");
processInfo.CreateNoWindow = false;
processInfo.UseShellExecute = false;
我收到错误无法找到RUNME.jar,但是如果我在命令提示符下手动运行do.cmd,它可以正常工作。但是如果我在c#中创建一个Process并运行它,我就会得到上面的错误。
所以我的问题是如何在c#中运行cmd,以便在cmd提示符下运行它?
答案 0 :(得分:1)
我能够通过做三件事来解决问题。
更改对象创建以仅包含命令(因为我设置了工作目录)
processInfo = new ProcessStartInfo("do.cmd");
将工作目录设置为do.cmd
processInfo.WorkingDirectory = Directory.GetCurrentDirectory() + $"\\somedir\\bin\\";
将UseShellExecute
设置为true
:
processInfo.UseShellExecute = true;