2013-12-20 43 views
1

我使用下面的代碼將參數傳遞到過程例外:字符串文件名太長(處理)

ProcessStartInfo StartInfo = new ProcessStartInfo(); 
StartInfo.FileName = HttpContext.Current.Server.MapPath(@"\highcharts\phantomjs.exe"); 
StartInfo.Arguments = HttpContext.Current.Server.MapPath(@"\highcharts\highcharts-convert.js"); 
StartInfo.Arguments += @" -outfile " + path + @"\chart" + templateData[i].ReportTemplateChartId + ".png -width 800 -infile " + chartoptions1; 
StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 
StartInfo.CreateNoWindow = false; 

chartoptions1我使用JSON字符串,但它會引發異常說字符串文件名太長了,所以我創建了一個文本文件並試圖通過它,但圖表圖像沒有生成。

+1

嘗試用'StartInfo.UseShellExecute = TRUE;'你也可以設置'StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath (@「\ highcharts」);'然後'StartInfo.FileName =「phantomjs.exe」;默認情況下爲' – Damith

+0

StartInfo.UseShellExecute = true;我們需要設置StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath(@「\ highcharts」); 當我們沒有確切的路徑 –

回答

0

this MSDN頁面,

在Windows Vista和早期版本的Windows操作系統 系統的加入充分 路徑過程的長度參數的長度必須小於2080 。在Windows 7和更高版本 ,長度必須小於32699.

你檢查的StartInfo.Arguments的長度是多少?

在另一部分,咋一看這個wiki頁Github上,

-infile:要轉換的文件,假定它是無論是JSON文件,輸入文件的腳本檢查有擴展名'.json',或者 ,否則它認爲它是一個svg文件。

因此,-infile應該是一個文件,而不是JSON內容。我想你的chartoptions1是相當大的,所以你有錯誤信息字符串文件名太長

Highcharts也可以檢查的infile路徑(256?)

的運行腳本應該至少讀訪問的infile,並應可分辨的長度;特別是如果你沒有指定一個工作目錄,你必須使用infile添加完整路徑,而不僅僅是文件名。

要調試,工作目錄的問題,簡單地用一個恆定的路徑來測試,如c:\test