简体   繁体   English

例外:字符串文件名太长(进程)

[英]Exception: string filename too long (Process)

I am using the code below to pass an argument to a process 我正在使用下面的代码将参数传递给进程

 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;  

In chartoptions1 I was using a JSON string, but it throws an exception saying string filename too long , so I created a text file and tried to pass it, but the chart image is not generated. chartoptions1我使用的是JSON字符串,但是它抛出异常,表明字符串filename太长 ,因此我创建了一个文本文件并尝试将其传递,但​​未生成图表图像。

From this MSDN page, MSDN页面中,

On Windows Vista and earlier versions of the Windows operating system, the length of the arguments added to the length of the full path to the process must be less than 2080. On Windows 7 and later versions, the length must be less than 32699. 在Windows Vista和早期版本的Windows操作系统上,添加到进程完整路径长度的参数长度必须小于2080。在Windows 7及更高版本上,长度必须小于32699。

Did you check the length of StartInfo.Arguments ? 您是否检查了StartInfo.Arguments的长度?

On the other part, a quick look at this wiki page on Github, 另一方面,快速浏览Github上的此Wiki页面,

-infile: The file to convert, assumes it's either a JSON file, the script checks for the input file to have the extension '.json', or otherwise it assumes it to be an svg file. -infile:要转换的文件,假定它是JSON文件,脚本检查输入文件的扩展名为“ .json”,否则假定它是svg文件。

So, -infile should be a file and not a JSON content. 因此, -infile应该是文件,而不是JSON内容。 I suppose your chartoptions1 is quite large, so you have the error message string filename too long . 我想您的chartoptions1很大,所以您的错误消息字符串filename太长了

Highcharts may also check the length of the infile path (256 ?) 高图还可以检查文件内路径的长度(256?)

The running script should have at least read access to the infile and should be resolvable ; 正在运行的脚本至少应具有对infile的读取权限,并且应可解析; especially if you don't specified a working directory, you have to add the full path with infile and not just the filename. 特别是如果您未指定工作目录,则必须使用infile而不是文件名添加完整路径。

To debug, a working directory issue, simply test with a constant path such as c:\\test 要调试工作目录问题,只需使用恒定路径(例如c:\\test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM