0
我已經使用了Rscript runner,但它不工作。我想從asp.net頁面使用c#執行r腳本,但它沒有執行
public static string SetupPath(string Rversion = "R-3.2.3")
{
var oldPath = System.Environment.GetEnvironmentVariable("PATH");
var rPath = System.Environment.Is64BitProcess ?
string.Format(@"C:\Program Files\R\R-3.2.3\bin\x64", Rversion) :
string.Format(@"C:\Program Files\R\R-3.2.3\bin\i386", Rversion);
if (!Directory.Exists(rPath))
throw new DirectoryNotFoundException(
string.Format(" R.dll not found in : {0}", rPath));
var newPath = string.Format("{0}{1}{2}", rPath,
System.IO.Path.PathSeparator, oldPath);
System.Environment.SetEnvironmentVariable("PATH", newPath);
return newPath.ToString() ;
}
此Button1_Click方法調用rscript運行器。
protected void Button1_Click(object sender, EventArgs e)
{
string s = SetupPath();
string args = "";
string r = @"D:\scr1.r";
var RcodeFilePath = string.Format(@"D:\scr1.r", "R-3.2.3");
//string c = RScriptRunner.RunFromCmd(RcodeFilePath, s);
string c = RScriptRunner.RunFromCmd(r, "rscript.exe");
Label1.Text = c;
}
你有什麼錯誤嗎? – Alexander
沒有錯誤或異常正在進行 –