Possible Duplicate:
Server.MapPath and running a command line utility from an ASP.NET application
Background:
I am trying to use this phantomjs tool to rasterize an SVG to PNG. It works when I manually run the EXE myself, but I can't make it work from a method in C#. I've even put breakpoints to make sure my path and arguments are correct.
The method starts by saving an SVG to file:///C:/SVG/
- it does this successfully. Then I try run the EXE which is located in my ASP.NET project (the .js file used by the tool is also there). If you check the link above, the EXE runs like this: phantomjs.exe rasterize.js [source] [destination]
. So my source is the newly created SVG file, and my destination is a folder in the ASP.NET project - the same folder that the EXE is in. I'm guessing it's something to do with Server.MapPath or IIS permissions, but I'm stumped.
Here's the code:
// the EXE and the .js file are both located in 'ProjectRoot/Utilities/'
// filename is the newly created SVG file - 'whatever.svg'
string filepath = "C:/SVG/";
string serverPath = Server.MapPath("/Utilities/");
string args = " rasterize.js " + Path.Combine("file:///", filepath, filename) + " " + filename.Replace(".svg", ".png");
Process p = Process.Start(new ProcessStartInfo(serverPath + "phantomjs.exe", args));
p.WaitForExit(3000);
Running it doesn't throw an exception, it just fails to create the PNG file. When I debug and take the values and run the tool myself, it works fine. What can I do to narrow down the problem?